private void BtnAdd_Click(object sender, EventArgs e) { try { using (SqlConnection sqlCon = new SqlConnection(conStr)) { int seat = int.Parse(txtTotalSeat.Text); string sql = "Insert into [Bus] values('" + txtBusNo.Text + "', " + cmbBusType.SelectedValue + ", " + seat + ", " + seat + ")"; SqlCommand cmd = new SqlCommand(sql, sqlCon); sqlCon.Open(); if (cmd.ExecuteNonQuery() > 0) { sqlCon.Close(); //closing connection for unintendent error AsignCounterForm asignCounter = new AsignCounterForm(txtBusNo.Text, this); asignCounter.ShowDialog(this); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["btnDel"].Index) { Bus bus = new Bus(); if (MessageBox.Show("Are you sure about deleting this Bus?", "Warning!", MessageBoxButtons.YesNo) == DialogResult.Yes) { bus.DelBus(dataGridView1.CurrentRow.Cells["no"].Value.ToString()); } RefreshGrid(); } else if (e.ColumnIndex == dataGridView1.Columns["btnReasign"].Index) { AsignCounterForm asignCounter = new AsignCounterForm(dataGridView1.CurrentRow.Cells["no"].Value.ToString()); asignCounter.ShowDialog(this); } }
private void AddCounterToolStripMenuItem_Click(object sender, EventArgs e) { AsignCounterForm asignCounter = new AsignCounterForm(dataGridView1.CurrentRow.Cells["no"].Value.ToString()); asignCounter.ShowDialog(this); }