//accept Edit private void btnOk_Click(object sender, EventArgs e) { try { BL_Controller.AddStation station = new BL_Controller.AddStation(); station.EditStation(txtStationID.Text, txtDate.Text, Convert.ToInt32(txtTarget.Text), Convert.ToInt32(txtActual.Text), Convert.ToInt32(txtVariance.Text)); this.dataGridViewStationID.DataSource = dataShow.Datashow(); MessageBox.Show("Edited successfully.", "Edit Station", MessageBoxButtons.OK, MessageBoxIcon.Information); btmAddStation.Visible = true; btnDeleteStation.Visible = true; btmRefresh.Visible = true; btmClose.Visible = true; btnEditStation.Visible = true; btnCancel.Visible = false; btnOk.Visible = false; selectData(); TestVariance(); txtStationID.ReadOnly = false; } catch (Exception ex) { MessageBox.Show("The Field is Empty!", "Edit Station", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ex.GetBaseException(); } //Calcolate Variance Value }
//Button to Delete Station private void btnDeleteStation_Click(object sender, EventArgs e) { lblMessage.Visible = false; try { BL_Controller.AddStation deleteStation = new BL_Controller.AddStation(); if (MessageBox.Show("Do you want to delete the station?", "Delete Station", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { deleteStation.DeleteStation(this.dataGridViewStationID.CurrentRow.Cells[0].Value.ToString()); this.dataGridViewStationID.DataSource = dataShow.Datashow(); txtStationID.Text = ""; txtDate.Text = ""; txtTarget.Text = ""; txtActual.Text = ""; txtVariance.Text = ""; MessageBox.Show("Delete successfully.", "Delete Station", MessageBoxButtons.OK, MessageBoxIcon.Information); selectData(); actualRowsCount = this.dataGridViewStationID.Rows.Count.ToString(); lblRowsNewCount.Text = actualRowsCount; TestVariance(); } else { MessageBox.Show("The deletion from the station was canceled.", "Delete Station", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { ex.GetBaseException(); MessageBox.Show("There are no more data!", "Delete Station", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
//Action to Verify the ID private void txtStationID_Validated(object sender, EventArgs e) { BL_Controller.AddStation station = new BL_Controller.AddStation(); DataTable dt = new DataTable(); dt = station.VerifyStationID(txtStationID.Text); if (dt.Rows.Count > 0) { MessageBox.Show("The ID is already added!\nPlease enter another ID", "Add ID", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtStationID.Focus(); txtStationID.SelectionStart = 0; txtStationID.SelectionLength = txtStationID.TextLength; } }
// Button to Add new Station private void btmAddStation_Click(object sender, EventArgs e) { try { BL_Controller.AddStation station = new BL_Controller.AddStation(); station.AddNewStation(txtStationID.Text, txtDate.Text, Convert.ToInt32(txtTarget.Text), Convert.ToInt32(txtActual.Text), Convert.ToInt32(txtVariance.Text)); MessageBox.Show("Add successfully.", "Add Station", MessageBoxButtons.OK, MessageBoxIcon.Information); txtStationID.Text = ""; txtDate.Text = ""; txtTarget.Text = ""; txtActual.Text = ""; txtVariance.Text = ""; //Data Refresh on the Data Grid View BL_Controller.DataShow dataShow = new BL_Controller.DataShow(); PL_Views.Assessment_Record.getAssessment_Record.dataGridViewStationID.DataSource = dataShow.Datashow(); //Add vlaue to Variable newRowsCount from data Grid View newRowsCount = Assessment_Record.getAssessment_Record.dataGridViewStationID.Rows.Count.ToString(); PL_Views.Assessment_Record.getAssessment_Record.lblMessage.Visible = true; // Add tow Values to Function CalculatnewStation string temp = PL_Views.Assessment_Record.getAssessment_Record.lblRowsNewCount.Text.ToString(); BL_Controller.CalculatNewStations numStation = new BL_Controller.CalculatNewStations(); int resul = numStation.calculatNewStations(Convert.ToInt32(temp), Convert.ToInt32(newRowsCount)); PL_Views.Assessment_Record.getAssessment_Record.lblMessage.Text = "(" + resul.ToString() + ") New Station Added."; } catch (Exception ex) { MessageBox.Show("The Field is Empty!", "Add Station", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); ex.GetBaseException(); } }