//Save to gara private void btnSaveGara_Click(object sender, EventArgs e) { if (check = false) { if (CheckIn_Up()) { string sqlINSERT = "INSERT INTO dbo.THONGTINXE( BienSoXe , HangXe ,DoiXe ,SoKhung , SoMay , SoKM) VALUES ( '" + txtBS.Text + "' ,N'" + txtHangXe.Text + "' ,N'" + txtDX.Text + "' ,N'" + txtSoKhung.Text + "' , N'" + txtSoMay.Text + "' , N'" + txtSoKM.Text + "' )"; SqlConnect connect = new SqlConnect(); connect.OpenConnect(); SqlCommand cmd = new SqlCommand(sqlINSERT, connect.Conn); cmd.ExecuteNonQuery(); LoadXe(); connect.CloseConnect(); lockTxtGara(); } else { MessageBox.Show("Bạn phải điền đầy đủ thông tin!"); } } else { if (CheckIn_Up()) { string sqlEDIT = "UPDATE THONGTINXE set DoiXe = '" + txtDX.Text + "' , SoKhung = '" + txtSoKhung.Text + "', SoMay = '" + txtSoMay.Text + "', SoKM = '" + txtSoKM.Text + "' where HangXe = '" + txtHangXe.Text + "' AND BienSoXe = '" + txtBS.Text + "'"; SqlConnect connect = new SqlConnect(); connect.OpenConnect(); SqlCommand cmd = new SqlCommand(sqlEDIT, connect.Conn); cmd.ExecuteNonQuery(); LoadXe(); connect.CloseConnect(); lockTxtGara(); } else { MessageBox.Show("Bạn cần chọn xe cần sửa!"); resetEnableBtn("done"); lockTxtGara(); } } resetTxtGara(); resetEnableBtn("done"); }
//delete gara private void btnDelGara_Click(object sender, EventArgs e) { if (CheckDel()) { if (MessageBox.Show("Bạn muốn xóa xe mang biển số " + txtBS.Text, "Quession", MessageBoxButtons.YesNo) != DialogResult.No) { string sqlDel = "delete from ThongTinXe where BienSoXe = '" + txtBS.Text + "'"; SqlConnect connect = new SqlConnect(); connect.OpenConnect(); SqlCommand cmd = new SqlCommand(sqlDel, connect.Conn); cmd.ExecuteNonQuery(); LoadXe(); connect.CloseConnect(); resetTxtGara(); } } else { MessageBox.Show("Bạn cần chọn xe muốn xóa trước!"); } }
//Exit to gara private void btnExitGara_Click(object sender, EventArgs e) { lockTxtGara(); resetTxtGara(); resetEnableBtn("done"); } //Save to gara private void btnSaveGara_Click(object sender, EventArgs e) { if (checkGara == "i") { if (CheckIn_Up()) { string sqlINSERT = "INSERT INTO dbo.THONGTINXE( BienSoXe , HangXe ,DoiXe ,SoKhung , SoMay , SoKM) VALUES ( '" + txtBS.Text + "' ,N'" + txtHangXe.Text + "' ,N'" + txtDX.Text + "' ,N'" + txtSoKhung.Text + "' , N'" + txtSoMay.Text + "' , N'" + txtSoKM.Text + "' )"; SqlConnect connect = new SqlConnect(); connect.OpenConnect(); SqlCommand cmd = new SqlCommand(sqlINSERT, connect.Conn); cmd.ExecuteNonQuery(); LoadXe(); connect.CloseConnect(); lockTxtGara(); } else { MessageBox.Show("Vui lòng điền đầy đủ thông tin!"); resetEnableBtn("done"); lockTxtGara(); } } if (checkGara=="u") { if (CheckIn_Up()) { string sqlEDIT = "UPDATE THONGTINXE set DoiXe = '" + txtDX.Text + "' , SoKhung = '" + txtSoKhung.Text + "', SoMay = '" + txtSoMay.Text + "', SoKM = '" + txtSoKM.Text + "' where HangXe = '" + txtHangXe.Text + "' AND BienSoXe = '" + txtBS.Text + "'"; SqlConnect connect = new SqlConnect(); connect.OpenConnect(); SqlCommand cmd = new SqlCommand(sqlEDIT, connect.Conn); cmd.ExecuteNonQuery(); LoadXe(); connect.CloseConnect(); lockTxtGara(); } else { MessageBox.Show("Vui lòng chọn xe cần sửa!"); resetTxtGara(); resetEnableBtn("done"); } } } /// <summary> /// bingding dataGridview to textbox is tbGara /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvGara_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewRow row = this.dgvGara.Rows[e.RowIndex]; txtBS.Text = row.Cells[0].Value.ToString(); txtHangXe.Text = row.Cells[1].Value.ToString(); txtDX.Text = row.Cells[2].Value.ToString(); txtSoKhung.Text = row.Cells[3].Value.ToString(); txtSoMay.Text = row.Cells[4].Value.ToString(); txtSoKM.Text = row.Cells[5].Value.ToString(); } } private void txtSearchGara_TextChanged(object sender, EventArgs e) { cmbShowGara.Enabled = true; searchGara(txtSearchGara.Text, cmbShowGara.Text); } private void cmbShowGara_SelectedIndexChanged(object sender, EventArgs e) { searchGara(txtSearchGara.Text, cmbShowGara.Text); } #endregion #region tbDoangThu private void btnThongKe_Click(object sender, EventArgs e) { LoadData(); DataBinding(); } private void btnxoaDT_Click_1(object sender, EventArgs e) { dgvThongKe.DataSource = thongKe.XoaThongKe(txthoadon.Text); LoadData(); DataBinding(); } private void btnxuatEL_Click_1(object sender, EventArgs e) { exportExcel(dgvThongKe, @"C:\Users\Vlit\Desktop\ttn", "doanhthu"); } private void chart1_Click(object sender, EventArgs e) { LoadBieuDo(); } #endregion private void frmQLGara_Load(object sender, EventArgs e) { LoadXe(); LoadCmbNhanVien(); AddXuong(); LoadNhanvien(); LoadPhutung(); lockTxtGara(); LoadCmbGara(); LoadBieuDo(); cmbShowGara.Enabled = false; //this.cmbShowGara.DropDownStyle = ComboBoxStyle.DropDownList; btnExitGara.Enabled = false; btnSaveGara.Enabled = false; } } }
//delete gara private void btnDelGara_Click(object sender, EventArgs e) { if (CheckDel()) { if (MessageBox.Show("Bạn muốn xóa xe mang biển số " + txtBS.Text, "Quession", MessageBoxButtons.YesNo) != DialogResult.No) { string sqlDel = "delete from ThongTinXe where BienSoXe = '" + txtBS.Text + "'"; SqlConnect connect = new SqlConnect(); connect.OpenConnect(); SqlCommand cmd = new SqlCommand(sqlDel, connect.Conn); cmd.ExecuteNonQuery(); LoadXe(); connect.CloseConnect(); resetTxtGara(); } } else { MessageBox.Show("Bạn cần chọn xe muốn xóa trước!"); } } //insert to gara private void btnInsertGara_Click(object sender, EventArgs e) { unlockTxtGara(); resetTxtGara(); showEnableBtn("insert"); checkGara = "i";