private void grid_CellEndEdit(object sender, DataGridViewCellEventArgs e) //원재료 검색 { conDataGridView grd = (conDataGridView)sender; DataGridViewCell cell = grd[e.ColumnIndex, e.RowIndex]; cell.Style.BackColor = Color.White; #region 공통 그리드 체크 if (grd.Columns[e.ColumnIndex].ToolTipText.IndexOf("명칭") >= 0 && grd._KeyInput == "enter") { string rat_mat_nm = (string)grd.Rows[e.RowIndex].Cells["RAW_MAT_NM"].Value; wnDm wDm = new wnDm(); DataTable dt = new DataTable(); dt = wDm.fn_Raw_List("where RAW_MAT_NM like '%" + rat_mat_nm + "%' "); if (dt.Rows.Count > 1) { //row가 2줄이 넘을 경우 팝업으로 넘어간다. Console.WriteLine("popup"); wConst.call_pop_raw_mat(grd, dt, e.RowIndex, rat_mat_nm, 1); //itemCompGridAdd(); } else if (dt.Rows.Count == 1) //row가 1일 경우 해당 row에 값을 자동 입력한다. { grd.Rows[e.RowIndex].Cells["RAW_MAT_CD"].Value = dt.Rows[0]["RAW_MAT_CD"].ToString(); grd.Rows[e.RowIndex].Cells["RAW_MAT_NM"].Value = dt.Rows[0]["RAW_MAT_NM"].ToString(); grd.Rows[e.RowIndex].Cells["OLD_RAW_MAT_NM"].Value = dt.Rows[0]["RAW_MAT_NM"].ToString(); //백업 키워드 grd.Rows[e.RowIndex].Cells["SPEC"].Value = dt.Rows[0]["SPEC"].ToString(); grd.Rows[e.RowIndex].Cells["IN_UNIT"].Value = dt.Rows[0]["INPUT_UNIT"].ToString(); grd.Rows[e.RowIndex].Cells["OUT_UNIT"].Value = dt.Rows[0]["OUTPUT_UNIT"].ToString(); grd.Rows[e.RowIndex].Cells["IN_UNIT_NM"].Value = dt.Rows[0]["INPUT_UNIT_NM"].ToString(); grd.Rows[e.RowIndex].Cells["OUT_UNIT_NM"].Value = dt.Rows[0]["OUTPUT_UNIT_NM"].ToString(); grd.Rows[e.RowIndex].Cells["TOTAL_AMT"].Value = "0"; itemCompGridAdd(); } else { //row가 없는 경우 MessageBox.Show("데이터가 없습니다."); } } #endregion 공통 그리드 체크 //string sSearchTxt = "" + (string)grd.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; }
private void popupLogic(object sender, DataGridViewCellEventArgs e) { conDataGridView grd = (conDataGridView)sender; DataGridViewCell cell = grd[e.ColumnIndex, e.RowIndex]; cell.Style.BackColor = Color.White; #region 공통 그리드 체크 if (grd.Columns[e.ColumnIndex].ToolTipText.IndexOf("명칭") >= 0 && grd._KeyInput == "enter") { string rat_mat_nm = (string)grd.Rows[e.RowIndex].Cells["RAW_MAT_NM"].Value; wnDm wDm = new wnDm(); DataTable dt = new DataTable(); StringBuilder sb = new StringBuilder(); sb.AppendLine("where RAW_MAT_NM like '%" + rat_mat_nm + "%' "); if (chk구매처.Checked == true) { sb.AppendLine(" and cust_cd = '" + txt_cust_cd.Text + "' "); } dt = wDm.fn_Raw_List(sb.ToString(), "1"); if (dt.Rows.Count > 1) { //row가 2줄이 넘을 경우 팝업으로 넘어간다. wConst.call_pop_raw_mat(grd, dt, e.RowIndex, rat_mat_nm, 2, txt_cust_cd.Text); //orderGridAdd(); } else if (dt.Rows.Count == 1) //row가 1일 경우 해당 row에 값을 자동 입력한다. { grd.Rows[e.RowIndex].Cells["RAW_MAT_CD"].Value = dt.Rows[0]["RAW_MAT_CD"].ToString(); grd.Rows[e.RowIndex].Cells["RAW_MAT_NM"].Value = dt.Rows[0]["RAW_MAT_NM"].ToString(); grd.Rows[e.RowIndex].Cells["OLD_RAW_MAT_NM"].Value = dt.Rows[0]["RAW_MAT_NM"].ToString(); grd.Rows[e.RowIndex].Cells["SPEC"].Value = dt.Rows[0]["SPEC"].ToString(); grd.Rows[e.RowIndex].Cells["UNIT_CD"].Value = dt.Rows[0]["INPUT_UNIT"].ToString(); grd.Rows[e.RowIndex].Cells["UNIT_NM"].Value = dt.Rows[0]["INPUT_UNIT_NM"].ToString(); grd.Rows[e.RowIndex].Cells["PRICE"].Value = dt.Rows[0]["INPUT_PRICE"].ToString(); if (rmOrderGrid.Rows[rmOrderGrid.Rows.Count - 1].Cells[2].Value != null) { orderGridAdd(); } } else { //row가 없는 경우 MessageBox.Show("데이터가 없습니다."); rmOrderGrid.Rows.RemoveAt(rmOrderGrid.SelectedRows[0].Index); rmOrderGrid.CurrentCell = rmOrderGrid[2, rmOrderGrid.Rows.Count]; //minus_logic(rmOrderGrid); } wConst.f_Calc_Price(grd, e.RowIndex, "TOTAL_AMT", "PRICE"); } if (grd.Columns[e.ColumnIndex].ToolTipText.IndexOf("수량") >= 0 || grd.Columns[e.ColumnIndex].ToolTipText.IndexOf("단가") >= 0 || grd.Columns[e.ColumnIndex].ToolTipText.IndexOf("금액") >= 0) { string total_amt = (string)grd.Rows[e.RowIndex].Cells["TOTAL_AMT"].Value; string input_price = (string)grd.Rows[e.RowIndex].Cells["PRICE"].Value; if (total_amt != null) { total_amt = total_amt.ToString().Replace(" ", ""); if (total_amt == "") { grd.Rows[e.RowIndex].Cells["TOTAL_AMT"].Value = "0"; } } else { grd.Rows[e.RowIndex].Cells["TOTAL_AMT"].Value = "0"; } if (input_price != null) { input_price = input_price.ToString().Replace(" ", ""); if (input_price == "") { grd.Rows[e.RowIndex].Cells["PRICE"].Value = "0"; } } else { grd.Rows[e.RowIndex].Cells["PRICE"].Value = "0"; } wConst.f_Calc_Price(grd, e.RowIndex, "TOTAL_AMT", "PRICE"); } #endregion 공통 그리드 체크 //string sSearchTxt = "" + (string)grd.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; }
private void grid_CellEndEdit(object sender, DataGridViewCellEventArgs e) { conDataGridView grd = (conDataGridView)sender; DataGridViewCell cell = grd[e.ColumnIndex, e.RowIndex]; cell.Style.BackColor = Color.White; #region 공통 그리드 체크 if (grd.Columns[e.ColumnIndex].ToolTipText.IndexOf("명칭") >= 0 && grd._KeyInput == "enter") { string rat_mat_nm = (string)grd.Rows[e.RowIndex].Cells["RAW_MAT_NM"].Value; wnDm wDm = new wnDm(); DataTable dt = new DataTable(); dt = wDm.fn_Raw_List("where RAW_MAT_NM like '%" + rat_mat_nm + "%' "); if (dt.Rows.Count > 1) { //row가 2줄이 넘을 경우 팝업으로 넘어간다. wConst.call_pop_raw_mat(grd, dt, e.RowIndex, rat_mat_nm, 2); //orderGridAdd(); } else if (dt.Rows.Count == 1) //row가 1일 경우 해당 row에 값을 자동 입력한다. { grd.Rows[e.RowIndex].Cells["RAW_MAT_CD"].Value = dt.Rows[0]["RAW_MAT_CD"].ToString(); grd.Rows[e.RowIndex].Cells["RAW_MAT_NM"].Value = dt.Rows[0]["RAW_MAT_NM"].ToString(); grd.Rows[e.RowIndex].Cells["OLD_RAW_MAT_NM"].Value = dt.Rows[0]["RAW_MAT_NM"].ToString(); grd.Rows[e.RowIndex].Cells["SPEC"].Value = dt.Rows[0]["SPEC"].ToString(); grd.Rows[e.RowIndex].Cells["UNIT_CD"].Value = dt.Rows[0]["INPUT_UNIT"].ToString(); grd.Rows[e.RowIndex].Cells["UNIT_NM"].Value = dt.Rows[0]["INPUT_UNIT_NM"].ToString(); grd.Rows[e.RowIndex].Cells["PRICE"].Value = dt.Rows[0]["INPUT_PRICE"].ToString(); grd.Rows[e.RowIndex].Cells["BOX_AMT"].Value = dt.Rows[0]["BOX_AMT"].ToString(); orderGridAdd(); } else { //row가 없는 경우 MessageBox.Show("데이터가 없습니다."); } //wConst.f_Calc_Price(grd, e.RowIndex, "TOTAL_AMT", "PRICE"); wConst.f_Calc_PriceAndBox(grd, e.RowIndex, "TOTAL_AMT", "PRICE", "BOX_AMT"); //wConst.f_Calc_Box(grd, e.RowIndex, "TOTAL_AMT", "BOX_AMT"); } if (grd.Columns[e.ColumnIndex].ToolTipText.IndexOf("수량") >= 0 || grd.Columns[e.ColumnIndex].ToolTipText.IndexOf("단가") >= 0 || grd.Columns[e.ColumnIndex].ToolTipText.IndexOf("금액") >= 0) { string total_amt = (string)grd.Rows[e.RowIndex].Cells["TOTAL_AMT"].Value; string input_price = (string)grd.Rows[e.RowIndex].Cells["PRICE"].Value; string box_amt = (string)grd.Rows[e.RowIndex].Cells["BOX_AMT"].Value; if (total_amt != null) { total_amt = total_amt.ToString().Replace(" ", ""); if (total_amt == "") { grd.Rows[e.RowIndex].Cells["TOTAL_AMT"].Value = "0"; } } else { grd.Rows[e.RowIndex].Cells["TOTAL_AMT"].Value = "0"; } if (input_price != null) { input_price = input_price.ToString().Replace(" ", ""); if (input_price == "") { grd.Rows[e.RowIndex].Cells["PRICE"].Value = "0"; } } else { grd.Rows[e.RowIndex].Cells["PRICE"].Value = "0"; } if (box_amt != null) { box_amt = box_amt.ToString().Replace(" ", ""); if (box_amt == "") { grd.Rows[e.RowIndex].Cells["BOX_AMT"].Value = "0"; } } else { grd.Rows[e.RowIndex].Cells["BOX_AMT"].Value = "0"; } //wConst.f_Calc_Price(grd, e.RowIndex, "TOTAL_AMT", "PRICE"); wConst.f_Calc_PriceAndBox(grd, e.RowIndex, "TOTAL_AMT", "PRICE", "BOX_AMT"); } #endregion 공통 그리드 체크 //string sSearchTxt = "" + (string)grd.Rows[e.RowIndex].Cells[e.ColumnIndex].Value; }