private void LoadTC() { String maTC = cmbMaTiecCuoi.Text; DTO.DTO_TiecCuoi tc = BUS_DatTiecCuoi.getThongTinTiecCuoi(maTC); if (tc == null) { HienThiDsMonAn(maTC); HienThiDsDichVu(maTC); CapNhatBtt(maTC); KiemTraSanhTrong(); return; } DTO.DTO_KhachHang kh = BUS_DatTiecCuoi.getThongTinKhachHang(tc.MA_KHACH_HANG); cmbSanh.Text = tc.MA_SANH.Trim(); cmbCa.Text = tc.MA_CA.Trim(); numSLBan.Value = tc.SL_BAN; numSLDuTru.Value = tc.SL_BAN_DU_TRU; tbDatCoc.Text = tc.TIEN_DAT_COC.ToString(); HienThiThongTinKH(kh); HienThiThongTinTC(tc); HienThiDsMonAn(maTC); HienThiDsDichVu(maTC); KiemTraSanhTrong(); CapNhatBtt(maTC); }
private void HienThiThongTinTC(DTO.DTO_TiecCuoi tc) { DTO.DTO_Sanh s = BUS_DatTiecCuoi.getThongTinSanh(tc.MA_SANH); DTO.DTO_Ca c = BUS_DatTiecCuoi.getThongTinCa(tc.MA_CA); dateTimePicker1.Text = tc.NGAY_TO_CHUC; cmbCa.Text = c.MA_CA; }
public static DTO.DTO_TiecCuoi getThongTinTiecCuoi(String maTC) { String sql = String.Format(@"SELECT * FROM TIEC_CUOI WHERE MA_TIEC_CUOI = '{0}'", maTC); Console.WriteLine(sql); DataTable da = DatabaseHelper.GetData(sql); DTO.DTO_TiecCuoi result = null; if (da.Rows.Count > 0) { Console.WriteLine("ok"); result = new DTO.DTO_TiecCuoi(); DataRow row = da.Rows[0]; result.MA_TIEC_CUOI = maTC; result.MA_KHACH_HANG = row["MA_KHACH_HANG"].ToString(); result.MA_SANH = row["MA_SANH"].ToString(); result.NGAY_TO_CHUC = row["NGAY_TO_CHUC"].ToString(); result.MA_CA = row["MA_CA"].ToString(); result.TIEN_DAT_COC = int.Parse(row["TIEN_DAT_COC"].ToString()); result.SL_BAN = int.Parse(row["SL_BAN"].ToString()); result.SL_BAN_DU_TRU = int.Parse(row["SL_BAN_DU_TRU"].ToString()); } Console.WriteLine("ok"); return(result); }
public static bool capNhatThongTinTiecCuoi(DTO.DTO_TiecCuoi tc) { String sql = String.Format(@"UPDATE TIEC_CUOI SET MA_KHACH_HANG = '{1}', MA_SANH = '{2}', NGAY_TO_CHUC = '{3}', MA_CA = '{4}', TIEN_DAT_COC = {5}, SL_BAN = {6}, SL_BAN_DU_TRU = {7} WHERE MA_TIEC_CUOI='{0}' ", tc.MA_TIEC_CUOI, tc.MA_KHACH_HANG, tc.MA_SANH, tc.NGAY_TO_CHUC, tc.MA_CA, tc.TIEN_DAT_COC, tc.SL_BAN, tc.SL_BAN_DU_TRU); if (DatabaseHelper.ExcuteSql(sql) > 0) { return(true); } return(false); }
public static bool themTiecCuoi(DTO.DTO_TiecCuoi tc) { String sql = String.Format(@"INSERT INTO TIEC_CUOI (MA_TIEC_CUOI, MA_KHACH_HANG, MA_SANH, NGAY_TO_CHUC, MA_CA, TIEN_DAT_COC, SL_BAN, SL_BAN_DU_TRU) VALUES ('{0}','{1}','{2}','{3}','{4}',{5},{6},{7})", tc.MA_TIEC_CUOI, tc.MA_KHACH_HANG, tc.MA_SANH, tc.NGAY_TO_CHUC, tc.MA_CA, tc.TIEN_DAT_COC, tc.SL_BAN, tc.SL_BAN_DU_TRU); Console.WriteLine(sql); if (DatabaseHelper.ExcuteSql(sql) > 0) { return(true); } return(false); }
private void TinhTienMonAn() { int sum = 0; DTO.DTO_TiecCuoi x = BUS_DatTiecCuoi.getThongTinTiecCuoi(cmbMaTiecCuoi.Text); if (x == null) { return; } int u = x.SL_BAN; for (int i = 0; i < dtMA.Rows.Count - 1; i++) { sum += int.Parse(dtMA.Rows[i].Cells[2].Value.ToString().Trim()); } sum *= u; lbTienAn.Text = sum.ToString(); }
private void Button9_Click(object sender, EventArgs e) { bool state = CheckThongTinTC(); if (!state) { return; } String maTC = cmbMaTiecCuoi.Text; String maKH = cmbMaKH.Text; String maS = cmbSanh.Text; String maCa = cmbCa.Text; String ngayToChuc = dateTimePicker1.Value.ToString("yyyy-MM-dd");; int tienDatCoc = int.Parse(tbDatCoc.Text); int slBan = int.Parse(numSLBan.Value.ToString()); int slDuTru = int.Parse(numSLDuTru.Value.ToString()); DTO.DTO_TiecCuoi tc = new DTO.DTO_TiecCuoi(maTC, maKH, maS, ngayToChuc, maCa, tienDatCoc, slBan, slDuTru); if (BUS_DatTiecCuoi.getDsMaTiecCuoi().Contains(maTC)) { if (BUS_DatTiecCuoi.capNhatThongTinTiecCuoi(tc)) { MessageBox.Show("Cập nhật thành công."); } else { MessageBox.Show("Cập nhật thất bại."); } } else { if (BUS_DatTiecCuoi.themTiecCuoi(tc)) { MessageBox.Show("Thêm thành công."); cmbMaTiecCuoi.Items.Add(maTC); CapNhatBtt(maTC); } else { MessageBox.Show("Thêm thất bại."); } } }
private void HienThiHoaDon(string ma) { DTO.DTO_TiecCuoi tc = BUS.BUS_LapHoaDon.getThongTinTiecCuoi(ma); DTO.DTO_KhachHang kh = BUS.BUS_LapHoaDon.getThongTinKhachHang(tc.MA_KHACH_HANG); DTO.DTO_Sanh sanh = BUS.BUS_LapHoaDon.getThongTinSanh(tc.MA_SANH); DTO.DTO_LoaiSanh ls = BUS.BUS_LapHoaDon.getThongTinLoaiSanh(sanh.MA_LOAI_SANH); lbTenChuRe.Text = kh.TEN_CHU_RE; lbTenCoDau.Text = kh.TEN_CO_DAU; lbSDT.Text = kh.SDT; lbSanh.Text = sanh.TEN_SANH; lbSLBan.Text = (tc.SL_BAN + tc.SL_BAN_DU_TRU).ToString(); lbDonGia.Text = ls.DON_GIA_TOI_THIEU.ToString(); lbNgayToChuc.Text = tc.NGAY_TO_CHUC.ToString().Split()[0]; lbTienDatCoc.Text = tc.TIEN_DAT_COC.ToString(); lbTongTienBan.Text = ((tc.SL_BAN + tc.SL_BAN_DU_TRU) * ls.DON_GIA_TOI_THIEU - tc.TIEN_DAT_COC).ToString(); HienThiDsMonAn(tc.MA_TIEC_CUOI); HienThiDsDichVu(tc.MA_TIEC_CUOI); TinhTienPhat(); }
public static bool UpdateTiecCuoi(DTO.DTO_TiecCuoi tiecCuoiInfo) { return(DAO.DAO_LapHoaDonThanhToan.UpdateTiecCuoi(tiecCuoiInfo)); }