private void btnApplyServerSetting_Click(object sender, EventArgs e) { using (var dialog = new frmPassword()) { if (dialog.ShowDialog() == DialogResult.OK) { var result = DialogResult.None; var newIP = txtServerAddress.Text.TrimEnd(); var newPort = txtServerPort.Text.TrimEnd(); if (helper.ConfigInfo == null) { return; } if (string.Equals(newIP, helper.ConfigInfo.SocketIpAddress) && string.Equals(newPort, helper.ConfigInfo.SocketPortNumber.ToString())) { result = PopupWindow.ShowDialog(ExceptionMessage.NothingChanged); } else { // popup warning message about how to active new configuration PopupWindow.ShowDialog("The IMESAgent must be restarted to active the new configuration.", UserMessage.Warning); helper.SaveIPAddressInfo(newIP, newPort); } } } }
private void btnDelete_Click(object sender, EventArgs e) { try { var grid = gridConfigruation; if (Discard() == true) { return; } if (grid == null) { return; } if (grid.SelectedRows == null || grid.SelectedRows.Count == 0) { return; } using (var dialog = new frmPassword()) { var result = dialog.ShowDialog(); if (result == DialogResult.OK) { var row = grid.SelectedRows[0]; if (row.Cells.Count > 0) { var id = SelectedRowIndex; if (!string.IsNullOrEmpty(id) && helper.GatheringPointTable != null) { for (int i = 0; i < helper.GatheringPointTable.Rows.Count; i++) { var dataRow = helper.GatheringPointTable.Rows[i]; if (id == dataRow[0].ToString()) { helper.RemoveGatheringInfo(id, dataRow); helper.SaveToCsv(PathManager.Instance.GatheringInfoPath, helper.GatheringPointTable); grid.Refresh(); Clear(); break; } } } } } } } catch (Exception ex) { PopupWindow.ShowDialog(ex.Message, UserMessage.Error); } }
private void btnApply_Click(object sender, EventArgs e) { try { if (!IsEmptyTextFeild()) { if (updating == false && adding == false) { return; } } else { return; } using (var dialog = new frmPassword()) { if (dialog.ShowDialog() == DialogResult.OK) { DataTable tab = null; var alias = txtAlias.Text.TrimEnd(); var bcrip = txtBCRIP.Text.TrimEnd(); var logPath = txtLogFolder.Text.TrimEnd(); var inspRoute = cbInspRoute.Text.TrimEnd(); var inspType = cbInspType.Text.TrimEnd(); if (adding == true) { var row = helper.GatheringPointTable.Rows.Add(); var i = gridConfigruation.Rows.GetLastRow(DataGridViewElementStates.None); gridConfigruation.Rows[i].Selected = true; tab = helper.SaveToDatatable(alias, bcrip, logPath, inspRoute, inspType); } else if (updating == true) { tab = helper.UpdateGatheringInfos(SelectedRowIndex, alias, bcrip, logPath, inspRoute, inspType); } if (adding || updating) { var status = helper.SaveToCsv(PathManager.Instance.GatheringInfoPath, tab); if (status) { PopupWindow.ShowDialog(ClientMessage.ActivateModification, UserMessage.Information); BindToGrid(tab); } else { PopupWindow.ShowDialog(ClientMessage.SaveFailed, UserMessage.Error); } } } } } catch (Exception ex) { PopupWindow.ShowDialog(ex.Message, UserMessage.Error); } finally { adding = false; updating = false; UpdateControlStatus(true); } }