using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using WindowsFormsApp1.Home; namespace WindowsFormsApp1.Delivery { public partial class Commodity_Search : Form { public string Clinet_name { get; internal set; } // 거래처 텍스트박스 내용 Commodity_registration com; Commodity_Edit edit; Purchase pur; List_aggregation la; public Commodity_Search(Purchase _pur) { InitializeComponent(); pur = _pur; } public Commodity_Search(Commodity_Edit _edit) { InitializeComponent(); edit = _edit; } public Commodity_Search(Commodity_registration _com) { InitializeComponent(); com = _com; } public Commodity_Search(List_aggregation _la) { InitializeComponent(); la = _la; } private void Commodity_Sub_Load(object sender, EventArgs e) { string compidx = ""; if (edit != null) { edit.New_Clit.Text = ""; compidx = edit.compidx; } if (com != null) { com.tb_clt1.Text = ""; compidx = com.comp_idx; } if (pur != null) { pur.tb_clt.Text = ""; compidx = pur.compidx; } if (la != null) { la.tb_clt.Text = ""; compidx = la.compidx; } Helper_DB db = new Helper_DB(); string Area = "`c_sangho`, `c_boss`, `c_tel`, `c_man`, `c_mantel`"; db.DBcon(); string dbcon = db.DB_Contains("Client", compidx, "c_sangho", Clinet_name, Area); string[] res = dbcon.Split('|'); string[] grid = { "", "", "", "", "" }; for(int a = 0; a < res.Length; a++) { if (a % 5 == 0) { grid[0] = res[a]; } if (a % 5 == 1) { grid[1] = res[a]; } if (a % 5 == 2) { grid[2] = res[a]; } if (a % 5 == 3) { grid[3] = res[a]; } if (a % 5 == 4) { grid[4] = res[a]; dataGridView1.Rows.Add(grid); } } } private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { string value = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(); if (edit != null) { edit.New_Clit.Text = value; } if (com != null) { com.tb_clt1.Text = value; } if (pur != null) { pur.tb_clt.Text = value; } if (la != null) { la.tb_clt.Text = value; } Close(); } private void dataGridView1_KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.Enter) { int gridIdx = dataGridView1.CurrentRow.Index; string value = ""; if (dataGridView1.Rows[gridIdx].Cells[0].Value != null) { value = dataGridView1.Rows[gridIdx].Cells[0].Value.ToString(); } else { value = ""; } if (edit != null) { edit.New_Clit.Text = value; } if (com != null) { com.tb_clt1.Text = value; } if (pur != null) { pur.tb_clt.Text = value; } if (la != null) { la.tb_clt.Text = value; } Close(); } if (e.KeyCode == Keys.Escape) { Close(); } } private void Commodity_Search_FormClosed(object sender, FormClosedEventArgs e) { if (pur != null) { pur.Made_Grid(pur.tb_clt.Text, pur.tb_clt.Name); } } } }