private void SetDataBind_gridView1() { Mem_WsDevice.WsDevice wSvc = null; string reCode = ""; string reMsg = ""; Mem_WsDevice.DataDevice[] getData = null; try { wSvc = new Mem_WsDevice.WsDevice(); wSvc.Url = "http://" + AppInfo.SsWsvcServer1 + "/WebSvc/Sys/Device/WsDevice.svc"; wSvc.Timeout = 1000; reCode = wSvc.sDevice(AppInfo.SsDbNm, AppInfo.SsSiteCd, out getData, out reMsg); //AppInfo.SsSiteCD if (reCode == "Y") { if (getData != null && getData.Length > 0) { dataGridView1.Rows.Clear(); for (int i = 0; i < getData.Length; i++) { dataGridView1.Rows.Add(); dataGridView1.Rows[i].Cells["dgv1_DEV_CD"].Value = getData[i].DEV_CD.ToString(); dataGridView1.Rows[i].Cells["dgv1_DEVICE_ID"].Value = getData[i].DEVICE_ID.ToString(); set_Grideview1Combo1(i, "dgv1_DEV_TYPE_SCD"); dataGridView1.Rows[i].Cells["dgv1_DEV_TYPE_SCD"].Value = getData[i].DEV_TYPE_SCD.ToString(); set_Grideview1Combo2(i, "dgv1_DEV_IO_SCD"); dataGridView1.Rows[i].Cells["dgv1_DEV_IO_SCD"].Value = getData[i].DEV_IO_SCD.ToString(); dataGridView1.Rows[i].Cells["dgv1_DEV_NM"].Value = getData[i].DEV_NM.ToString(); dataGridView1.Rows[i].Cells["dgv1_IP"].Value = getData[i].IP.ToString(); dataGridView1.Rows[i].Cells["dgv1_USING_FLAG"].Value = getData[i].USING_FLAG.ToString(); dataGridView1.Rows[i].Cells["dgv1_SORT_NO"].Value = getData[i].SORT_NO.ToString(); dataGridView1.Rows[i].Cells["dgv1_MEMO"].Value = getData[i].MEMO.ToString(); } SetRowNumber(dataGridView1); } } } catch (Exception ex) { logs.SaveLog("[error] (page)::FrmAccessDevice.cs (Function)::SetDataBind_gridView1 (Detail)::reMsg=[" + reMsg + "]", "Error"); logs.SaveLog("[error] (page)::FrmAccessDevice.cs (Function)::SetDataBind_gridView1 (Detail):: " + "\r\n" + ex.ToString(), "Error"); } finally { if (wSvc != null) { wSvc.Dispose(); } } }
//DEV TYPE COMBO private void set_Grideview1Combo1(int rnum, string column_name) { Mem_WsDevice.WsDevice wSvc = null; string reCode = ""; string reMsg = ""; Mem_WsDevice.DataDevCombo[] getData = null; try { wSvc = new Mem_WsDevice.WsDevice(); wSvc.Url = "http://" + AppInfo.SsWsvcServer1 + "/WebSvc/Sys/Device/WsDevice.svc"; wSvc.Timeout = 1000; reCode = wSvc.devTypeCmb(out getData, out reMsg); if (reCode == "Y") { if (getData != null && getData.Length > 0) { Class.Common.ComboBoxItemSet setCmb = null; setCmb = new Class.Common.ComboBoxItemSet(); setCmb.AddColumn(); for (int i = 0; i < getData.Length; i++) { setCmb.AddRow(getData[i].SCODE_NM.ToString(), getData[i].SCODE.ToString()); } DataGridViewComboBoxCell constCombo1 = new DataGridViewComboBoxCell(); constCombo1.DisplayMember = "TEXT"; constCombo1.ValueMember = "VALUE"; constCombo1.DataSource = setCmb.GetDataTable(); dataGridView1.Rows[rnum].Cells[column_name] = constCombo1; } } } catch (Exception ex) { logs.SaveLog("[error] (page)::FrmAccessDevice.cs (Function)::SetDataBind_CmbMember (Detail):: " + "\r\n" + ex.ToString()); } }
//수정 private void btnSave_Click(object sender, EventArgs e) { Mem_WsDevice.WsDevice wSvc = null; string reCode = ""; string reMsg = ""; string reData = "0"; try { wSvc = new Mem_WsDevice.WsDevice(); wSvc.Url = "http://" + AppInfo.SsWsvcServer1 + "/WebSvc/Sys/Device/WsDevice.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; for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (dataGridView1.Rows[i].Cells["dgv1_DEV_CD"].Value != null) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value != null) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value.ToString() == "1") { string pDbNm = AppInfo.SsDbNm; string pSiteCd = AppInfo.SsSiteCd; string pDevCd = dataGridView1.Rows[i].Cells["dgv1_DEV_CD"].Value.ToString(); //Invisible string pDeviceId = ""; if (dataGridView1.Rows[i].Cells["dgv1_DEVICE_ID"].Value == null) { MessageBox.Show(msgRM.GetString("msgNoneDeviceName")); return; } else { pDeviceId = dataGridView1.Rows[i].Cells["dgv1_DEVICE_ID"].Value.ToString(); } string pDevTypeScd = dataGridView1.Rows[i].Cells["dgv1_DEV_TYPE_SCD"].Value.ToString(); string pDevIOScd = dataGridView1.Rows[i].Cells["dgv1_DEV_IO_SCD"].Value.ToString(); string pDevNm = ""; if (dataGridView1.Rows[i].Cells["dgv1_DEV_NM"].Value != null) { pDevNm = dataGridView1.Rows[i].Cells["dgv1_DEV_NM"].Value.ToString(); } string pIp = ""; if (dataGridView1.Rows[i].Cells["dgv1_IP"].Value != null) { pIp = dataGridView1.Rows[i].Cells["dgv1_IP"].Value.ToString(); } string pSortNo = "10"; if (dataGridView1.Rows[i].Cells["dgv1_SORT_NO"].Value != null) { pSortNo = dataGridView1.Rows[i].Cells["dgv1_SORT_NO"].Value.ToString(); } string pUsingFlag = dataGridView1.Rows[i].Cells["dgv1_USING_FLAG"].Value.ToString(); string pMemo = ""; if (dataGridView1.Rows[i].Cells["dgv1_MEMO"].Value != null) { pMemo = dataGridView1.Rows[i].Cells["dgv1_MEMO"].Value.ToString(); } //UPDATE reCode = wSvc.mDevice(pDbNm, pSiteCd, pDevCd, pDeviceId, pDevTypeScd, pDevIOScd, pDevNm, pIp, pSortNo, pUsingFlag, pMemo, out reMsg, out reData); //UPDATE LOG wSvc.logDevice(pDbNm, pDevCd, pSiteCd, pDeviceId, pDevTypeScd, pDevIOScd, pDevNm, pIp, pUsingFlag, pSortNo, pMemo, AppInfo.SsLabNo, out reMsg, out reData); if (reCode == "Y" && reData != "0") { reCnt += Convert.ToInt16(reData); } } } } //DEV_CD 저장 버튼에서 추가가 일어난다. (DEV_CD 를 INVISIBLE로 해놨기 때문에 추가에는 DEV_CD가 NULL) else if (dataGridView1.Rows[i].Cells["dgv1_DEV_CD"].Value == null) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value != null) { if (dataGridView1.Rows[i].Cells["dgv1_CHK"].Value.ToString() == "1") { string pDbNm = AppInfo.SsDbNm; string pSiteCd = AppInfo.SsSiteCd; string pDeviceId = ""; if (dataGridView1.Rows[i].Cells["dgv1_DEVICE_ID"].Value == null) { MessageBox.Show(msgRM.GetString("msgNoneDeviceId")); SetDataBind_gridView1(); return; } else { pDeviceId = dataGridView1.Rows[i].Cells["dgv1_DEVICE_ID"].Value.ToString(); } string pDevTypeScd = ""; if (dataGridView1.Rows[i].Cells["dgv1_DEV_TYPE_SCD"].Value == null) { MessageBox.Show(msgRM.GetString("msgNoneDeviceType")); SetDataBind_gridView1(); return; } else { pDevTypeScd = dataGridView1.Rows[i].Cells["dgv1_DEV_TYPE_SCD"].Value.ToString(); } string pDevIOScd = ""; if (dataGridView1.Rows[i].Cells["dgv1_DEV_IO_SCD"].Value == null) { MessageBox.Show(msgRM.GetString("msgNoneDeviceInOut")); SetDataBind_gridView1(); return; } else { pDevIOScd = dataGridView1.Rows[i].Cells["dgv1_DEV_IO_SCD"].Value.ToString(); } string pDevNm = ""; if (dataGridView1.Rows[i].Cells["dgv1_DEV_NM"].Value != null) { pDevNm = dataGridView1.Rows[i].Cells["dgv1_DEV_NM"].Value.ToString(); } string pIp = ""; if (dataGridView1.Rows[i].Cells["dgv1_IP"].Value != null) { pIp = dataGridView1.Rows[i].Cells["dgv1_IP"].Value.ToString(); } string pSortNo = "10"; if (dataGridView1.Rows[i].Cells["dgv1_SORT_NO"].Value != null) { pSortNo = dataGridView1.Rows[i].Cells["dgv1_SORT_NO"].Value.ToString(); } string pUsingFlag = "1"; string pMemo = ""; if (dataGridView1.Rows[i].Cells["dgv1_MEMO"].Value != null) { pMemo = dataGridView1.Rows[i].Cells["dgv1_MEMO"].Value.ToString(); } string[] param = new string[10]; param[0] = AppInfo.SsSiteCd; param[1] = pDeviceId; param[2] = pDevTypeScd; param[3] = pDevIOScd; param[4] = pDevNm; param[5] = pIp; param[6] = pUsingFlag; param[7] = pSortNo; param[8] = pMemo; param[9] = AppInfo.SsLabNo; //INSERT WITH PROCEDURE reCode = wSvc.aDevicePro(AppInfo.SsDbNm, param, out reData, out reMsg); if (reCode == "Y" && reData != "0") { reCnt += Convert.ToInt16(reData); } } } } } if (reCnt > 0) { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wSuccess")); } else { MessageBox.Show(wRM.GetString("wSave") + " " + wRM.GetString("wFail")); } SetDataBind_gridView1(); } catch (Exception ex) { logs.SaveLog("[error] (page)::FrmSysAuthSiteDB.cs (Function)::btnSave_Click (Detail):: " + "\r\n" + ex.ToString(), "Error"); } finally { if (wSvc != null) { wSvc.Dispose(); } } }