private void btnSave_Click(object sender, EventArgs e) { M_WsCodeTMainDB.WsCodeTMainDB wSvc = null; string reCode = ""; string reMsg = ""; string reData = ""; M_WsCodeTMainDB.DataCodeTSub[] getData = null; //_formCodeT.btnSearch_Click try { wSvc = new M_WsCodeTMainDB.WsCodeTMainDB(); wSvc.Url = "http://" + AppInfo.SsWsvcServer2 + "/WebSvc/Sys/CodeT/WsCodeTMainDB.svc"; wSvc.Timeout = 1000; int reCnt = 0; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value != null) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value.ToString() == "1") { reCnt++; } } } if (reCnt < 1) { MessageBox.Show(msgRM.GetString("msgNotSelected")); return; } reCnt = 0; if (btnSave.Text == wRM.GetString("wApply")) { for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value != null) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value.ToString() == "1") { string[] param = new string[9]; param[0] = dataGridView1.Rows[i].Cells["dgv1_TCODE"].Value.ToString(); param[1] = dataGridView1.Rows[i].Cells["dgv1_TTYPE_SCD"].Value.ToString(); param[2] = dataGridView1.Rows[i].Cells["dgv1_NM"].Value.ToString(); param[3] = dataGridView1.Rows[i].Cells["dgv1_REQUIRED_FLAG"].Value.ToString(); param[4] = dataGridView1.Rows[i].Cells["dgv1_NUMERIC_FLAG"].Value.ToString(); param[5] = dataGridView1.Rows[i].Cells["dgv1_LIST_FLAG"].Value.ToString(); param[6] = AppInfo.SsLabNo; param[7] = AppInfo.SsSiteCd; param[8] = _formCodeTSite.getTgrpCcd(); reCode = wSvc.aCodeTSite(AppInfo.SsDbNm, param, out reMsg, out reData); if (reData == "2") { MessageBox.Show(msgRM.GetString("msgAlreadyUsed")); return; } else { if (dataGridView1.Rows[i].Cells["dgv1_TTYPE_SCD"].Value.ToString() == "Combobox") { reCode = wSvc.sCodeTSubTscode(param[0], out getData, out reMsg); if (reCode == "Y") { if (getData != null && getData.Length > 0) { for (int j = 0; j < getData.Length; j++) { string[] paramSub = new string[5]; paramSub[0] = param[0]; paramSub[1] = getData[j].TSCODE.ToString(); paramSub[2] = getData[j].TSCODE_NM.ToString(); paramSub[3] = AppInfo.SsLabNo; paramSub[4] = AppInfo.SsSiteCd; reCode = wSvc.aCodeTSubSite(AppInfo.SsDbNm, paramSub, out reMsg, out reData); } } } } if (reCode == "Y" && reData != "" && reData != "2") { reCnt += Convert.ToInt16(reData); } } } } } if (reCnt > 0) { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wSuccess") + " : " + reCnt.ToString()); } else { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wFail")); } _formCodeTSite.Popup_End(); SetDataBind_gridView1(_codeGrp, _code); } else if (_codeGrp == "1") { for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value != null) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value.ToString() == "1") { string tcode_val = dataGridView1.Rows[i].Cells["dgv1_TCODE"].Value.ToString(); string listFlag_val = dataGridView1.Rows[i].Cells["dgv1_LIST_FLAG"].Value.ToString(); string requiredFlag_val = dataGridView1.Rows[i].Cells["dgv1_REQUIRED_FLAG"].Value.ToString(); string numericFlag_val = dataGridView1.Rows[i].Cells["dgv1_NUMERIC_FLAG"].Value.ToString(); reCode = wSvc.mCodeT(tcode_val, listFlag_val, requiredFlag_val, numericFlag_val, out reMsg, out reData); if (reCode == "Y" && reData != "") { reCnt += Convert.ToInt16(reData); } } } } if (reCnt > 0) { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wSuccess") + " : " + reCnt.ToString()); } else { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wFail")); } SetDataBind_gridView1(_codeGrp, _code); } } catch (Exception ex) { logs.SaveLog("[error] (page)::FrmCodeTMainDB.cs (Function)::btnSave_Click (Detail):: " + "\r\n" + ex.ToString(), "Error"); } finally { if (wSvc != null) { wSvc.Dispose(); } } }
private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e) { M_WsCodeTMainDB.WsCodeTMainDB wSvc = null; string reCode = ""; string reMsg = ""; string reData = ""; string colNm = dataGridView2.Columns[e.ColumnIndex].Name; if (colNm == "dgv2_BTNADD") { if (_codeGrp == "1") { string reVal = ChkDgv2Param(); if (reVal != "") { MessageBox.Show(wRM.GetString("wCheck") + " :: " + reVal); } else { string tCode_val = dataGridView2.Rows[0].Cells["dgv2_TCODE"].Value.ToString(); string tCodeNm_val = dataGridView2.Rows[0].Cells["dgv2_NM"].Value.ToString(); string listFlag_val = "0"; if (dataGridView2.Rows[0].Cells["dgv2_LIST_FLAG"].Value != null) { listFlag_val = dataGridView2.Rows[0].Cells["dgv2_LIST_FLAG"].Value.ToString(); } string requiredFlag_val = "0"; if (dataGridView2.Rows[0].Cells["dgv2_REQUIRED_FLAG"].Value != null) { requiredFlag_val = dataGridView2.Rows[0].Cells["dgv2_REQUIRED_FLAG"].Value.ToString(); } string numericFlag_val = "0"; if (dataGridView2.Rows[0].Cells["dgv2_NUMERIC_FLAG"].Value != null) { numericFlag_val = dataGridView2.Rows[0].Cells["dgv2_NUMERIC_FLAG"].Value.ToString(); } try { wSvc = new M_WsCodeTMainDB.WsCodeTMainDB(); wSvc.Url = "http://" + AppInfo.SsWsvcServer2 + "/WebSvc/Sys/CodeT/WsCodeTMainDB.svc"; wSvc.Timeout = 1000; reCode = wSvc.exCodeT(tCode_val, tCodeNm_val, out reMsg, out reData); if (reCode == "Y" && reData != "0") { MessageBox.Show(msgRM.GetString("msgDuplicated")); } else { reCode = ""; reCode = wSvc.aCodeT(tCode_val, _code, tCodeNm_val, listFlag_val, requiredFlag_val, numericFlag_val, AppInfo.SsLabNo, out reMsg, out reData); if (btnSave.Text == wRM.GetString("wApply")) { string[] param = new string[9]; param[0] = tCode_val; param[1] = _code; param[2] = tCodeNm_val; param[3] = requiredFlag_val; param[4] = numericFlag_val; param[5] = listFlag_val; param[6] = AppInfo.SsLabNo; param[7] = AppInfo.SsSiteCd; param[8] = _formCodeTSite.getTgrpCcd(); reCode = wSvc.aCodeTSite(AppInfo.SsDbNm, param, out reMsg, out reData); _formCodeTSite.Popup_End(); } int reCnt = 0; if (reCode == "Y" && reData != "") { reCnt = Convert.ToInt16(reData); } if (reCnt > 0) { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wSuccess") + " : " + reCnt.ToString()); } else { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wFail")); } SetDataBind_gridView1(_codeGrp, _code); } } catch (Exception ex) { logs.SaveLog("[error] (page)::FrmCodeTMainDB.cs (Function)::dataGridView2_CellClick (Detail):: " + "\r\n" + ex.ToString(), "Error"); } finally { if (wSvc != null) { wSvc.Dispose(); } } } } if (_codeGrp == "2") { string reVal = ChkDgv2Param(); if (reVal != "") { MessageBox.Show(wRM.GetString("wCheck") + " :: " + reVal); } else { string tCode_val = dataGridView2.Rows[0].Cells["dgv2_TCODE"].Value.ToString(); string tscodeNm_val = dataGridView2.Rows[0].Cells["dgv2_NM"].Value.ToString(); try { wSvc = new M_WsCodeTMainDB.WsCodeTMainDB(); wSvc.Url = "http://" + AppInfo.SsWsvcServer2 + "/WebSvc/Sys/CodeT/WsCodeTMainDB.svc"; wSvc.Timeout = 1000; reCode = wSvc.exCodeTSub(tCode_val, tscodeNm_val, out reMsg, out reData); if (reCode == "Y" && reData != "0") { MessageBox.Show(msgRM.GetString("msgDuplicated")); } else { reCode = ""; reCode = wSvc.aCodeTSub(tCode_val, tscodeNm_val, "0", AppInfo.SsLabNo, out reMsg, out reData); int reCnt = 0; if (reCode == "Y" && reData != "") { reCnt = Convert.ToInt16(reData); } if (reCnt > 0) { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wSuccess") + " : " + reCnt.ToString()); } else { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wFail")); } SetDataBind_gridView1(_codeGrp, _code); } } catch (Exception ex) { logs.SaveLog("[error] (page)::FrmCodeTMainDB.cs (Function)::dataGridView2_CellClick (Detail):: " + "\r\n" + ex.ToString(), "Error"); } finally { if (wSvc != null) { wSvc.Dispose(); } } } } } }