private void btnThem_Click(object sender, EventArgs e) { if (dgvDsDia.SelectedRows.Count > 0 && nudSoLuong.Value > 0) { eDia dia = dgvDsDia.Rows[dgvDsDia.CurrentRow.Index].DataBoundItem as eDia; eChiTietHoaDon newItem = new eChiTietHoaDon(); newItem.maDia = dia.maDia; newItem.soLuong = (int)nudSoLuong.Value; newItem.thanhTien = dia.donGia; newItem.tenDia = dia.tenDia; int index = -1; foreach (eChiTietHoaDon item in lstChiTiet) { index++; if (item.maDia == newItem.maDia) { lstChiTiet[index].soLuong += (int)nudSoLuong.Value; lstChiTiet[index].thanhTien = lstChiTiet[index].soLuong * dia.donGia; eChiTietHoaDonBindingSource.DataSource = lstChiTiet; eChiTietHoaDonBindingSource.ResetBindings(false); dataGridView2.Refresh(); return; } } lstChiTiet.Add(newItem); eChiTietHoaDonBindingSource.DataSource = lstChiTiet; eChiTietHoaDonBindingSource.ResetBindings(false); dataGridView2.Refresh(); } }
ePhieuThue phatSinhPhieuThueTheoDia(eDia dia) { eLoaiDia loai = busLoai.LayLoaiDiaTheoDia(dia); //Tìm loại của đĩa if (loai == null) //Không tìm được loại { return(null); } else //Tìm được loại { ePhieuThue ept = new ePhieuThue() { Maphieuthue = "", Giathue = loai.giaThue, Ngaymuon = DateTime.Now, Ngayhentra = DateTime.Now.AddDays(loai.thoiGianThue), Makhachhang = kh.Makh, Madia = dia.Madia, Trangthaithue = "Đang thuê", Ngaytra = null, Phitramuon = null, Trangthaiphi = null }; return(ept); } }
public void LoadFormTT() { if (k == 2) { return; } int rowSelected = 0; try { rowSelected = dataGridView1.CurrentRow.Index; } catch (Exception ex) { return; } try { eDia dia = ser.GetDiaByID(int.Parse(dataGridView1.Rows[rowSelected].Cells[0].Value.ToString().Trim())); tbxID.Text = dia.maDia.ToString(); tbxTenDia.Text = dia.tenDia; tbxDonGia.Text = dia.donGia.ToString(); numSL.Value = dia.soLuong; cbTheLoai.SelectedValue = dia.maTheLoai; pictureBox1.Image = ByteToImg(Convert.ToBase64String(dia.HinhAnh)); } catch (Exception e) { } }
public bool EditDia(eDia dia) { try { Dia t = db.Dias.Where(x => x.MaDia == dia.maDia).FirstOrDefault(); if (t != null) { t.MaTheLoai = dia.maTheLoai; t.TenDia = dia.tenDia; t.DonGia = dia.donGia; t.SoLuong = dia.soLuong; t.HinhAnh = dia.HinhAnh; db.SaveChanges(); return(true); } else { return(false); } } catch (Exception) { return(false); } }
public GanDia(QuyTrinhTraDia frmMain, eDia dia) { InitializeComponent(); frmTra = frmMain; tenFormGoi = "QuyTrinhTraDia"; diaGan = new eDia(); diaGan = dia; }
public GanDia(QuyTrinhXoaDat frmMain, eDia dia) { InitializeComponent(); frmXDat = frmMain; tenFormGoi = "QuyTrinhXoaDat"; diaGan = new eDia(); diaGan = dia; }
private void btnXoa_Click(object sender, EventArgs e) { #region Xóa if (Form_Main.trangThaiLogin != true) { XtraMessageBox.Show("Vui lòng đăng nhập tài khoản quản lý để thực hiện chức năng này !"); formDN = new Form_QuanLy.Form_DangNhap(); formDN.ShowDialog(); } // Vì khách hàng có thể làm mất đĩa nên vẫn có thể xóa được đĩa trong trạng thái thuê, đoạn code dưới dùng để kiểm tra đĩa còn ở của hàng ko. //else if(diabll.kiemTraDiaTaiCuaHang(tbThem_IdDia.Text) != true) //{ // XtraMessageBox.Show("Đĩa này đang được thuê bởi một khách hàng, không thể xóa !"); //} else if (Form_Main.trangThaiLogin == true) { #region diglog DialogResult dg = new DialogResult(); dg = XtraMessageBox.Show("Bạn có muốn xóa đĩa này không, thao tác này không thể hoàn tác !", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dg == DialogResult.Yes) { try { eDia dia = new eDia(); dia.IdDia = tbIdDia.Text; dia.TrangThaiXoa = true; if (diabll.XoaDia(dia)) { XtraMessageBox.Show("Xóa đĩa thành công !"); dataGridViewD.DataSource = null; LoadDataDia(dataGridViewTD.CurrentRow.Cells[0].Value.ToString()); tdbll.capnhatSoLuong(dataGridViewTD.CurrentRow.Cells[0].Value.ToString()); dataGridViewTD.DataSource = null; dataGridViewTD.DataSource = tdbll.LayDanhSachTieuDeTheoTenDanhMuc(cbbPhanLoaiDanhMuc.SelectedValue.ToString()); XoaPanel(); panelQuanLyTD.Enabled = false; btnLuu.Enabled = false; btnHuy.Enabled = false; btnThem.Enabled = true; KEY = 0; } } catch (Exception ex) { XtraMessageBox.Show("Lỗi: " + ex); } } else { dg = DialogResult.Cancel; } #endregion } #endregion }
public eDia layDiaTheoMa(string madia) { Dia d = db.Dias.Where(x => x.MaDia == madia).FirstOrDefault(); eDia ed = new eDia(); ed.Madia = d.MaDia; ed.Tendia = d.TenDia; ed.Matieude = d.MaTieuDe; ed.Trangthaidia = d.TrangThaiDia; return(ed); }
public int ThemDia(eDia d) { Dia dia = new Dia(); dia.MaDia = sinhMaDiaTuSo(chisoDia() + 1); dia.TenDia = d.Tendia; dia.MaTieuDe = d.Matieude; dia.TrangThaiDia = d.Trangthaidia; db.Dias.InsertOnSubmit(dia); db.SubmitChanges(); return(1); }
public bool XoaDia(eDia ed) { Dia d = new Dia(); d = db.Dias.Where(a => a.IdDia == ed.IdDia).SingleOrDefault(); if (d != null && d.TrangThaiThue == "cosan") { d.TrangThaiXoa = ed.TrangThaiXoa; db.SubmitChanges(); return(true); } return(false); }
public eDia layDiaGanDatTruoc(string maKH, string maTD) { var dia = (from pd in db.PhieuDats join d in db.Dias on pd.MaDia equals d.MaDia where (pd.MaKhachHang.Equals(maKH) && pd.MaTieuDe.Equals(maTD) && pd.TrangThai.Equals("Đã có đĩa")) select d).FirstOrDefault(); eDia tam = new eDia(); tam.Matieude = dia.MaTieuDe; tam.Madia = dia.MaDia; tam.Trangthaidia = dia.TrangThaiDia; tam.Tendia = dia.TenDia; return(tam); }
void DanhSachThueDat(List <ePhieuDat> lstDat) { foreach (var item in lstDat) { eDia temp = busDIA.layDiaTheoMa(item.MaDia); if (temp != null) { ePhieuThue ept = phatSinhPhieuThueTheoDia(temp); if (ept != null) { lstThueDat.Add(ept); } } } }
public eDia GetDiaByID(int id) { eDia lst = db.Dias.Where(x => x.MaDia == id).Select(t => new eDia { maDia = t.MaDia, maTheLoai = t.MaTheLoai.Value, tenDia = t.TenDia, donGia = t.DonGia.Value, tenTheLoai = t.TheLoai.TenTheLoai, HinhAnh = t.HinhAnh, soLuong = t.SoLuong.Value }).FirstOrDefault(); return(lst); }
public List <eDia> LayDiaCoTen(string ten) { List <eDia> l = new List <eDia>(); List <Dia> lst = db.Dias.Where(x => x.TenDia.Contains(ten)).ToList(); foreach (var item in lst) { eDia ed = new eDia(); ed.Madia = item.MaDia; ed.Tendia = item.TenDia; ed.Matieude = item.MaTieuDe; ed.Trangthaidia = item.TrangThaiDia; l.Add(ed); } return(l); }
public List <eDia> layDiaDangThueCuaTieuDe(string matieude) { List <eDia> l = new List <eDia>(); List <Dia> lst = db.Dias.Where(x => x.MaTieuDe.Equals(matieude) && (x.TrangThaiDia.Equals("Đã thuê") || x.TrangThaiDia.Equals("Đã đặt"))).ToList(); foreach (var item in lst) { eDia ed = new eDia(); ed.Madia = item.MaDia; ed.Tendia = item.TenDia; ed.Matieude = item.MaTieuDe; ed.Trangthaidia = item.TrangThaiDia; l.Add(ed); } return(l); }
public List <eDia> layToanBoDiaChoQLDia() { List <eDia> l = new List <eDia>(); List <Dia> lst = db.Dias.ToList(); foreach (var item in lst) { eDia ed = new eDia(); ed.Madia = item.MaDia; ed.Tendia = item.TenDia; ed.Matieude = item.MaTieuDe; ed.Trangthaidia = item.TrangThaiDia; l.Add(ed); } return(l); }
public bool ThemDia(eDia ed) { Dia d = new Dia(); d.IdDia = ed.IdDia; d.TrangThaiThue = ed.TrangThaiThue; d.TrangThaiXoa = ed.TrangThaiXoa; d.IdTieuDe = ed.IdTieuDe; if (!db.Dias.Contains(d)) { db.Dias.InsertOnSubmit(d); db.SubmitChanges(); return(true); } return(false); }
private void btnThemDia_Click(object sender, EventArgs e) { if (tbIdDia.Text == "" || tbIdDia.Text == "") { XtraMessageBox.Show("Thông tin thiếu, vui lòng nhập ID đĩa !"); } else if (tdbll.LayTenTieuDeBangIdDia(tbIdDia.Text) == "null") { XtraMessageBox.Show("Không có Đĩa này trong hệ thống, vui lòng nhập ID khác !"); } else if (diabll.kiemTraDiaTaiCuaHang(tbIdDia.Text) == false) { XtraMessageBox.Show("Đĩa đang có sẵn trong cửa hàng và chưa được thuê bởi ai , vui lòng nhập ID đĩa khác !"); } else { ekh = khbll.LayThongTinKhachHangBangIdDia(tbIdDia.Text); ed = diabll.LayThongTinDiaBangIdDia(tbIdDia.Text); ettpt = ctptbll.LayThongTinPhieuThue(tbIdDia.Text, ekh.IdKhachHang); HienThiThongTinKH(); HienThiThongTinDia(); HienThiThongTinThueDia(); if (ettpt.SoNgayTreHan <= 0) { btnXNTD_BT.Enabled = true; btnXNTD_TraPhi.Enabled = false; btnXNTD_ChuaTraPhi.Enabled = false; btnHuy.Enabled = true; } else { if (ettpt.SoNgayTreHan > 0) { btnXNTD_TraPhi.Enabled = true; btnXNTD_ChuaTraPhi.Enabled = true; btnXNTD_BT.Enabled = false; btnHuy.Enabled = true; } } } }
private void TraDia_Load(object sender, EventArgs e) { busPT = new busPhieuThue(); busDIA = new busDia(); ePT = new ePhieuThue(); dia = new eDia(); tbxTenKH.ReadOnly = true; tbxDiaChi.ReadOnly = true; tbxSoDienThoai.ReadOnly = true; tbxMaPhieu.ReadOnly = true; tbxNgayHenTra.Enabled = false; tbxNgayThue.Enabled = false; tbxNgayTra.Enabled = false; tbxPhiMuon.ReadOnly = true; btnThanhToan.Enabled = false; lstthanhtoan = new List <ePhieuThue>(); lstPhiChuaThanhToan = new List <ePhieuThue>(); }
private void btnXoaDatTruoc_Click(object sender, EventArgs e) { if (dgvKhachHang.SelectedRows.Count > 0) { if (dgvKhachHang.SelectedRows.Count > 0) { maKH = dgvKhachHang.CurrentRow.Cells["makh"].Value.ToString(); dia = new eDia(); dia = busPD.layDiaGanDatTruoc(dgvTieuDe.CurrentRow.Cells["maPhieuDat"].Value.ToString()); if (busPD.XoaDatTruoc(dgvTieuDe.CurrentRow.Cells["maPhieuDat"].Value.ToString())) { MessageBox.Show("Xóa thành công"); if (dia == null) { dgvKhachHang.Columns.Clear(); listKH = busPD.layDanhSachKhachHangDaDatTruoc(); dgvKhachHang.DataSource = listKH; TaoTenCotChoKhachHang(); dgvTieuDe.Columns.Clear(); listPD = busPD.LayDanhSachDatTruocCuaKhach(maKH); dgvTieuDe.DataSource = listPD; TaoTenCotChoTieuDe(); } else { busDia.updateTrangThaiDiaTra(dia.Madia); main.GoNext(); } } else { MessageBox.Show("Xóa thất bại"); } } else { MessageBox.Show("Vui lòng chọn tiều đề cần xóa !"); } } else { MessageBox.Show("Vui lòng chọn khách hàng cần xóa !"); } }
public List <eDia> LayDanhSachDia(string IdTieuDe) { List <eDia> list = new List <eDia>(); var query = (from a in db.TieuDes join b in db.Dias on a.IdTieuDe equals b.IdTieuDe where b.TrangThaiXoa == false && a.IdTieuDe == IdTieuDe select new { b.IdDia, b.TrangThaiThue }); foreach (var item in query) { eDia etd = new eDia(item.IdDia, item.TrangThaiThue); list.Add(etd); } return(list); }
private void btnLuu_Click(object sender, EventArgs e) { eDia d = new eDia(); d.maDia = int.Parse(tbxID.Text.Trim()); d.tenDia = tbxTenDia.Text.Trim(); d.maTheLoai = int.Parse(cbTheLoai.SelectedValue.ToString().Trim()); d.tenTheLoai = cbTheLoai.SelectedText.Trim(); d.soLuong = int.Parse(numSL.Value.ToString().Trim()); d.donGia = double.Parse(tbxDonGia.Text.Trim()); d.HinhAnh = converterDemo(pictureBox1.Image); if (k == 2)//them { bool r = ser.AddDia(d); if (r == true) { MessageBox.Show("Thêm thành công"); LoadDatagrib((List <eDia>)ser.GetAllDia("", "").ToList()); pictureBox1.Image = ByteToImg(Convert.ToBase64String(byteImage)); ClearTB(); tbxID.Text = (ser.GetAllDia("", "").Max(x => x.maDia) + 1).ToString(); } else { MessageBox.Show("Thêm thất bại"); } } else if (k == 1)//sua { bool r = ser.EditDia(d); if (r == true) { MessageBox.Show("Sửa thành công"); LoadDatagrib((List <eDia>)ser.GetAllDia("", "").ToList()); } else { MessageBox.Show("Sửa thất bại"); } } }
public bool AddDia(eDia dia) { try { Dia t = new Dia(); t.MaTheLoai = dia.maTheLoai; t.MaDia = dia.maDia; t.TenDia = dia.tenDia; t.DonGia = dia.donGia; t.SoLuong = dia.soLuong; t.HinhAnh = dia.HinhAnh; db.Dias.Add(t); db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public eLoaiDia LayLoaiDiaTheoDia(eDia dia) { TieuDe td = db.TieuDes.Where(x => x.MaTieuDe.Equals(dia.Matieude)).FirstOrDefault(); if (td != null) { LoaiDia loai = db.LoaiDias.Where(x => x.MaLoaiDia.Equals(td.MaLoaiDia)).FirstOrDefault(); if (loai != null) { eLoaiDia eloai = new eLoaiDia(); eloai.maLoai = loai.MaLoaiDia; eloai.tenLoai = loai.TenLoaiDia; eloai.thoiGianThue = loai.ThoiGianThue; eloai.giaThue = loai.GiaThue; eloai.giaPhat = loai.GiaPhat; return(eloai); } } return(null); }
private void btnLuu_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(tbxDia.Text) && !String.IsNullOrWhiteSpace(tbxDia.Text)) { eDia dia = new eDia() { Madia = "", Matieude = tdChon.MaTieuDe, Tendia = tbxTen.Text + tbxDia.Text, Trangthaidia = tbxTrangThai.Text }; busD.ThemDia(dia); MessageBox.Show("Thêm thành công!"); Close(); } else { MessageBox.Show("Cần nhập thêm đuôi cho tên đĩa để phân biệt với tiêu đề!"); tbxDia.Focus(); } }
public eDia LayThongTinDiaBangIdDia(string idDia) { eDia ed = new eDia(); var d = (from a in db.Dias join b in db.TieuDes on a.IdTieuDe equals b.IdTieuDe join c in db.DanhMucs on b.IdDanhMuc equals c.IdDanhMuc where a.IdDia == idDia select new { a.IdDia, b.TenTieuDe, c.TenDanhMuc, c.PhiThue, c.PhiTreHan }).Single(); ed.IdDia = d.IdDia; ed.TenTieuDe = d.TenTieuDe; ed.TenDanhMuc = d.TenDanhMuc; ed.PhiTreHan = Convert.ToDecimal(d.PhiTreHan); ed.PhiThue = Convert.ToDecimal(d.PhiThue); return(ed); }
public eDia layDiaGanDatTruoc(string ma) { var dia = (from pd in db.PhieuDats join d in db.Dias on pd.MaDia equals d.MaDia where (pd.MaDat.Equals(ma) && pd.TrangThai.Equals("Đã có đĩa")) select d).FirstOrDefault(); if (dia != null) { eDia tam = new eDia(); tam.Matieude = dia.MaTieuDe; tam.Madia = dia.MaDia; tam.Trangthaidia = dia.TrangThaiDia; tam.Tendia = dia.TenDia; return(tam); } else { return(null); } }
private void btnThanhToan_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Bạn có chắc chắn thực hiện ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (dr == DialogResult.OK) { //Xu ly neu thanh toan dia moi if (lstthanhtoan.Count == 0 && checkBox1.Checked == true) { int kq = busPT.updatePhiTraMuonMoiCoTraPhi(tbxMaPhieu.Text.ToString(), Double.Parse(tbxPhiMuon.Text.ToString())); if (kq == 1) { DialogResult dr1 = MessageBox.Show("Đĩa đã được trả, số tiền thanh toán là:" + Double.Parse(lblTienThanhToan.Text.ToString())); if (dr1 == DialogResult.OK) { this.Hide(); eDia dia = busDIA.layDiaTheoMa(ePT.Madia); GanDia frmGanDia = new GanDia(dia); frmGanDia.ShowDialog(); } } } //Xu ly neu thanh toan dia cu ma khong thanh toan dia moi else if (lstthanhtoan.Count > 0 && checkBox1.Checked == false) { int kq = updateDanhSachPhiMuonCu(lstthanhtoan); int kq2 = busPT.updatePhiTraMuonMoiKhongTraPhi(tbxMaPhieu.Text.ToString(), Double.Parse(tbxPhiMuon.Text.ToString())); if (kq == 1 && kq2 == 1) { DialogResult dr1 = MessageBox.Show("Phí muộn cũ đã được thanh toán, số tiền thanh toán là:" + Double.Parse(lblTienThanhToan.Text.ToString())); if (dr1 == DialogResult.OK) { this.Hide(); eDia dia = busDIA.layDiaTheoMa(ePT.Madia); GanDia frmGanDia = new GanDia(dia); frmGanDia.ShowDialog(); } } } //Xu ly neu thanh toan dia moi va dia cu else if (lstthanhtoan.Count > 0 && checkBox1.Checked == true) { int kq = busPT.updatePhiTraMuonMoiCoTraPhi(tbxMaPhieu.Text.ToString(), Double.Parse(tbxPhiMuon.Text.ToString())); int kq2 = updateDanhSachPhiMuonCu(lstthanhtoan); if (kq == 1 && kq2 == 1) { DialogResult dr1 = MessageBox.Show("Trả đĩa thành công, phí muộn cũ đã được thanh toán, số tiền thanh toán là:" + Double.Parse(lblTienThanhToan.Text.ToString())); if (dr1 == DialogResult.OK) { this.Hide(); eDia dia = busDIA.layDiaTheoMa(ePT.Madia); GanDia frmGanDia = new GanDia(dia); frmGanDia.ShowDialog(); } } } else { int kq = busPT.updatePhiTraMuonMoiKhongTraPhi(tbxMaPhieu.Text.ToString(), Double.Parse(tbxPhiMuon.Text.ToString())); if (kq == 1) { DialogResult dr1 = MessageBox.Show("Trả đĩa thành công,số tiền thanh toán là:" + Double.Parse(lblTienThanhToan.Text.ToString())); if (dr1 == DialogResult.OK) { this.Hide(); eDia dia = busDIA.layDiaTheoMa(ePT.Madia); GanDia frmGanDia = new GanDia(dia); frmGanDia.ShowDialog(); } } } } }
public int ThemDia(eDia d) { return(dalDIA.ThemDia(d)); }
public eLoaiDia LayLoaiDiaTheoDia(eDia dia) { return(dalld.LayLoaiDiaTheoDia(dia)); }