private void btnDanhSachXe_Click(object sender, EventArgs e) { this.Hide(); DanhSachXe danhSachXe = new DanhSachXe(); danhSachXe.Show(); }
private void btnHuy_Click(object sender, EventArgs e) { DanhSachXe danhSachXe = new DanhSachXe(); this.Hide(); danhSachXe.Show(); this.Close(); }
private void btnXacNhan_Click(object sender, EventArgs e) { try { conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandText = "insert into KhachHang ([tenKh],[cmnd],[diaChi],[sdt],[trangThai])" + " values('" + txtTen.Text + "', '" + txtCmnd.Text + "','" + txtDiaChi.Text + "', '" + txtSdt.Text + "', '" + 0 + "' )"; command.ExecuteNonQuery(); string sql = "select top 1 maKh from KhachHang order by maKh desc"; SqlCommand cmd = new SqlCommand(sql, conn); using (DbDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { maKh = Convert.ToInt32(reader.GetValue(0)); } } } SqlCommand commandInsert = conn.CreateCommand(); commandInsert.CommandText = "insert into HopDong ([maXe],[maKh],[maDv],[ngayBd],[maNV],[trangThai]) " + "values ('" + txtMaXe.Text + "', '" + maKh.ToString() + "','" + (comboDv.SelectedIndex + 1).ToString() + "', '" + dateBD.Value.ToShortDateString() + "', '" + 1 + "', '" + 0 + "' )"; commandInsert.ExecuteNonQuery(); MessageBox.Show("Thuê thành công", "Thông báo", MessageBoxButtons.OK); SqlCommand commandUpdate = conn.CreateCommand(); commandUpdate.CommandText = "update Xe SET [trangThai] = 1 where maXe = " + md.maXe; commandUpdate.ExecuteNonQuery(); DanhSachXe danhSachXe = new DanhSachXe(); this.Hide(); danhSachXe.Show(); this.Close(); } catch (Exception ex) { MessageBox.Show("Nhập thông tin không hợp lệ", "Cảnh báo", MessageBoxButtons.OK); } finally { conn.Close(); } }