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; 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; } 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; } Helper_DB db = new Helper_DB(); db.DBcon(); string dbcon = db.DB_Contains("Client", compidx, "c_sangho", Clinet_name); string[] res = dbcon.Split('|'); int cout = 0; for (int a = 0; a < res.Length/8; a++) { dataGridView1.Rows.Add(); } for(int a = 0; a < res.Length; a++) { if (a % 24 == 1) { dataGridView1.Rows[cout].Cells[0].Value = res[a]; } else if (a % 24 == 2) { dataGridView1.Rows[cout].Cells[1].Value = res[a]; } else if (a % 24 == 8) { dataGridView1.Rows[cout].Cells[2].Value = res[a]; } else if (a % 24 == 12) { dataGridView1.Rows[cout].Cells[3].Value = res[a]; } else if (a % 24 == 13) { dataGridView1.Rows[cout].Cells[4].Value = res[a]; cout++; } } } 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; } 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; } 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); } } } }