private void btnLuu_Click(object sender, EventArgs e) { if (Them) { try { if (this.txtTongTien.Text.Length == 0) { if (this.cmbHinhThuc.Text == "Tạm Thời") { if (this.cmbLX.Text == "Xe Đạp") { this.txtTongTien.Text = "3000 Đồng"; } else if (this.cmbLX.Text == "Xe Máy") { this.txtTongTien.Text = "5000 Đồng"; } else { this.txtTongTien.Text = "20000 Đồng"; } } else { if (this.cmbLX.Text == "Xe Đạp") { this.txtTongTien.Text = "80000 Đồng"; } else if (this.cmbLX.Text == "Xe Máy") { this.txtTongTien.Text = "100000 Đồng"; } else { this.txtTongTien.Text = "500000 Đồng"; } } } BLQLHoaDon blHD = new BLQLHoaDon(); blHD.ThemHD(this.txtMaKH.Text, this.txtTenKH.Text, this.txtDiaChi.Text, this.txtDienThoai.Text, this.txtBienSo.Text, this.cmbLX.Text, this.mskNgayGui.Text, this.cmbHinhThuc.Text, this.txtTongTien.Text, ref err); LoadData(); MessageBox.Show("Đã thêm xong!"); } catch (SqlException) { MessageBox.Show("Không thêm được!"); } } else { try { int r = dgvHD.CurrentCell.RowIndex; string strHD = dgvHD.Rows[r].Cells[0].Value.ToString(); BLQLHoaDon blHD = new BLQLHoaDon(); blHD.CapNhatHD(this.txtMaKH.Text, this.txtTenKH.Text, this.txtDiaChi.Text, this.txtDienThoai.Text, this.txtBienSo.Text, this.cmbLX.Text, this.mskNgayGui.Text, this.cmbHinhThuc.Text, this.txtTongTien.Text, ref err); LoadData(); MessageBox.Show("Đã lưu xong!"); } catch (SqlException) { MessageBox.Show("Không lưu được!"); } } }