/// <summary> /// the NO must be unique /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { try { if (Discard() == true) { return; } if (adding == false) { Clear(); UpdateControlStatus(false); InitializeRouteComboBox(); adding = true; } } 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); } }