internal frmNewBeam(Common.ExceptionHandler ExceptionTarget, Common.ChildFormClosed FormClosed, Components.BeamInfo Beam) { InitializeComponent(); this.ExHandler = ExceptionTarget; this.ChildClosed = FormClosed; this._Beam = Beam; _StiffnerFormA = new frmStiffner(); _StiffnerFormB = new frmStiffner(); _BearingFormA = new frmBearingPlate(); _BearingFormB = new frmBearingPlate(); _UserFormA = new frmUserDefined(); _UserFormB = new frmUserDefined(); _ExtrasForm = new frmExtras(); //All of this block is just to get the lookup codes from the database for the dropdown. Common.dbConnection.Open(); List <string> _DropdownOptions = new List <string>(); SQLiteCommand command = new SQLiteCommand("select lookup from SteelLookup"); command.Connection = Common.dbConnection; SQLiteDataReader reader = command.ExecuteReader(); while (reader.Read()) { _DropdownOptions.Add(reader.GetString(0)); } Common.dbConnection.Close(); cmbBeamType.DataSource = _DropdownOptions; cmbBeamType.Text = "W813"; }
private void btnAdd_Click(object sender, EventArgs e) { Int32 _NextRowID = 1; if (GridViewSource.Count > 0) { DataRow[] _temprow = GridViewSource.Select("ItemNumber=MAX(ItemNumber)"); _NextRowID = 1 + Int32.Parse(_temprow[0][0].ToString()); } switch (cmbTypeSelect.Text) { case "Beam": Components.BeamInfo _Beam = new Components.BeamInfo(_NextRowID, LaborTimings); BeamForm = new Forms.frmNewBeam(ExceptionTarget, ChildClosed, _Beam); DialogResult beamresult = BeamForm.ShowDialog(); if (beamresult == DialogResult.OK) { GridViewSource.ImportRow(_Beam.GetUIRow()); Parts.Add(_Beam.RowID, _Beam); GridViewSource.AcceptChanges(); dataGridView1.DataSource = GridViewSource; if (_Beam.Highlight) { _HighlightRows.Add(dataGridView1.Rows.Count - 2); } } BeamForm.Dispose(); break; case "Column": Components.ColumnInfo _Column = new Components.ColumnInfo(_NextRowID, LaborTimings); ColumnForm = new Forms.frmNewColumn(ExceptionTarget, ChildClosed, _Column); DialogResult columnresult = ColumnForm.ShowDialog(); if (columnresult == DialogResult.OK) { GridViewSource.ImportRow(_Column.GetUIRow()); Parts.Add(_Column.RowID, _Column); GridViewSource.AcceptChanges(); dataGridView1.DataSource = GridViewSource; if (_Column.Highlight) { _HighlightRows.Add(dataGridView1.Rows.Count - 2); } } ColumnForm.Dispose(); break; case "Handrail": Components.HandrailInfo _Handrail = new Components.HandrailInfo(_NextRowID, LaborTimings); HandrailForm = new Forms.frmNewHandrail(ExceptionTarget, ChildClosed, _Handrail); DialogResult Handrailresult = HandrailForm.ShowDialog(); if (Handrailresult == DialogResult.OK) { GridViewSource.ImportRow(_Handrail.GetUIRow()); Parts.Add(_Handrail.RowID, _Handrail); GridViewSource.AcceptChanges(); dataGridView1.DataSource = GridViewSource; if (_Handrail.Highlight) { _HighlightRows.Add(dataGridView1.Rows.Count - 2); } } HandrailForm.Dispose(); break; case "Stairs": Components.StairsInfo _Stairs = new Components.StairsInfo(_NextRowID, LaborTimings); StairsForm = new Forms.frmNewStairs(ExceptionTarget, ChildClosed, _Stairs); DialogResult Stairsresult = StairsForm.ShowDialog(); if (Stairsresult == DialogResult.OK) { GridViewSource.ImportRow(_Stairs.GetUIRow()); Parts.Add(_Stairs.RowID, _Stairs); GridViewSource.AcceptChanges(); dataGridView1.DataSource = GridViewSource; if (_Stairs.Highlight) { _HighlightRows.Add(dataGridView1.Rows.Count - 2); } } StairsForm.Dispose(); break; case "Edge Angle": Components.EdgeAngleInfo _EdgeAngle = new Components.EdgeAngleInfo(_NextRowID, LaborTimings); EdgeAngleForm = new Forms.frmNewEdgeAngle(ExceptionTarget, ChildClosed, _EdgeAngle); DialogResult EdgeAngleresult = EdgeAngleForm.ShowDialog(); if (EdgeAngleresult == DialogResult.OK) { GridViewSource.ImportRow(_EdgeAngle.GetUIRow()); Parts.Add(_EdgeAngle.RowID, _EdgeAngle); GridViewSource.AcceptChanges(); dataGridView1.DataSource = GridViewSource; if (_EdgeAngle.Highlight) { _HighlightRows.Add(dataGridView1.Rows.Count - 2); } } EdgeAngleForm.Dispose(); break; default: break; } //Re-highlight the datagrid after adding a new row (because it resets formatting) foreach (int _RowNum in _HighlightRows) { dataGridView1.Rows[_RowNum].DefaultCellStyle = _HighlightStyle; } }