private void AddButton_Click(object sender, EventArgs e) { bool isInteger = false; bool isDateTme = false; int id; DateTime dt; if (WellPadComboBox.SelectedIndex > -1 && IDTextBox.Text.Length > 0 && SpudDateTextBox.Text.Length > 0) { isInteger = Int32.TryParse(IDTextBox.Text, out id); isDateTme = DateTime.TryParse(SpudDateTextBox.Text, out dt); if (WellPadComboBox.SelectedIndex > -1 && isInteger == true && isDateTme == true) { int selectedIndex = WellPadComboBox.SelectedIndex; // getting index from combo box choice var well = WellFactories.GetFactory("Production").GetWell(); // getting well from wellFactories well.Id = Convert.ToInt32(IDTextBox.Text); well.SprudDate = DateTime.Parse(SpudDateTextBox.Text); ProdWell prodWell = well as ProdWell; //cast to ProdWell type to have a list of OilProduction pads[selectedIndex].Wells.Add(prodWell); //add well to well list for the selected wellPad MessageBox.Show("Production Well Added"); MainForm.isChanged = true; //sign for checker this.Close(); } else { MessageBox.Show("ID should be INTEGER, \nand/or Spud Date is in wrong format"); } } else { MessageBox.Show("All fields are Mandatory"); } }
private void SubmitButton_Click(object sender, EventArgs e) { bool isInteger = false; int numOfBarrels; bool isDateTme = false; DateTime dt; if (WellPadcomboBox.SelectedIndex > -1 && WellComboBox.SelectedIndex > -1 && BarrelsProducedTextBox.Text.Length > 0 && prodDateTextBox.Text.Length > 0) { isInteger = Int32.TryParse(BarrelsProducedTextBox.Text, out numOfBarrels); if (isInteger == false) { MessageBox.Show("Number of produced barrels must be an INTEGER"); } isDateTme = DateTime.TryParse(prodDateTextBox.Text, out dt); if (isDateTme == false) { MessageBox.Show("Date should be in DateTime format"); } if (isInteger == true && isDateTme == true) { string selectedW = this.WellComboBox.GetItemText(this.WellComboBox.SelectedItem); prodWell = wellPad.Wells.Find(w => w.Id.ToString() == selectedW) as ProdWell; prodWell.DailyProduction.Add(new OilProduction { BarrelsProduced = Convert.ToInt32(BarrelsProducedTextBox.Text), ProductionDate = DateTime.Parse(prodDateTextBox.Text) }); MessageBox.Show("Oil Production Entry Added"); MainForm.isChanged = true; //sign for checker this.Close(); } } else { MessageBox.Show("All fields are mandatory"); } }
private void SubmitButton_Click(object sender, EventArgs e) { bool isInteger = false; int numOfBarrels; bool isDateTme = false; DateTime dt; if (WellPadcomboBox.SelectedIndex > -1 && WellComboBox.SelectedIndex > -1 && BarrelsProducedTextBox.Text.Length > 0 && prodDateTextBox.Text.Length > 0) { isInteger = Int32.TryParse(BarrelsProducedTextBox.Text, out numOfBarrels); if (isInteger == false) { MessageBox.Show("Number of produced barrels must be an INTEGER"); } isDateTme = DateTime.TryParse(prodDateTextBox.Text, out dt); if (isDateTme == false) { MessageBox.Show("Date should be in DateTime format"); } if (isInteger == true && isDateTme == true) { string selectedW = this.WellComboBox.GetItemText(this.WellComboBox.SelectedItem); prodWell = wellPad.Wells.Find(w => w.Id.ToString() == selectedW) as ProdWell; prodWell.DailyProduction.Add(new OilProduction {BarrelsProduced = Convert.ToInt32(BarrelsProducedTextBox.Text), ProductionDate = DateTime.Parse(prodDateTextBox.Text)}); MessageBox.Show("Oil Production Entry Added"); MainForm.isChanged = true; //sign for checker this.Close(); } } else { MessageBox.Show("All fields are mandatory"); } }