Пример #1
0
        private void btnThemThuTien_Click(object sender, EventArgs e)
        {
            string       thutienID = txtMaThuTien.Text;
            PHIEUTHUTIEN thutien   = db.PHIEUTHUTIENs.Where(p => p.MaThuTien == thutienID).SingleOrDefault();

            if (thutien != null)
            {
                MessageBox.Show("Mã thu tiền đã tồn tại");
                return;
            }
            if (thutien == null)
            {
                PHIEUTHUTIEN p = new PHIEUTHUTIEN()
                {
                    MaThuTien   = thutienID,
                    NgayThuTien = DateTime.Parse(txtNgayThuTien.Text),
                    SoTienThu   = int.Parse(txtSoTienThu.Text),
                    TienConLai  = int.Parse(txtTienConLai.Text),
                };
                db.PHIEUTHUTIENs.Add(p);
                db.SaveChanges();
                LoadDataThuTien();
                MessageBox.Show("Thêm phiếu thu tiền thành công");
            }
        }
Пример #2
0
        //insert
        public bool Insert(DateTime ngayThuTien, int soTienThu, string maDL)
        {
            string       maPTT = PhieuThuTienDAO.Instance.CreateCode();
            PHIEUTHUTIEN temp  = new PHIEUTHUTIEN();

            temp.MaPhieuThu  = maPTT;
            temp.NgayThuTien = ngayThuTien;
            temp.SoTienThu   = soTienThu;
            temp.MaDaiLy     = maDL;


            return(PhieuThuTienDAO.Instance.Insert(temp));
        }
Пример #3
0
        private void btnXoaThuTien_Click(object sender, EventArgs e)
        {
            string       thutienID = txtMaThuTien.Text;
            PHIEUTHUTIEN thutien   = db.PHIEUTHUTIENs.Where(p => p.MaThuTien == thutienID).SingleOrDefault();

            if (thutien != null)
            {
                db.PHIEUTHUTIENs.Remove(thutien);
                db.SaveChanges();
                LoadDataThuTien();
                MessageBox.Show("Xoá phiếu thu tiền thành công");
            }
        }
Пример #4
0
 //insert
 public bool Insert(PHIEUTHUTIEN dl)
 {
     using (QLDLDataContext db = new QLDLDataContext())
     {
         try
         {
             db.PHIEUTHUTIENs.InsertOnSubmit(dl);
             db.SubmitChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Пример #5
0
        private void btnTim_Click(object sender, EventArgs e)
        {
            string MaPT = txtMaPhieuThu.Text;

            MaPT = MaPT.TrimEnd();
            if (MaPT != "")
            {
                PHIEUTHUTIEN temp = PhieuThuTienBUS.Instance.GetByID(MaPT);
                if (temp != null)
                {
                    //gán thông tin phiếu thu
                    txtTien.Text = temp.SoTienThu.ToString();
                    dTPK.Value   = temp.NgayThuTien.Value;
                    cmbMaDL.Text = temp.MaDaiLy;
                    //gán thông tin đại lý
                    DAILY dl = DaiLyBUS.Instance.GetByID(temp.MaDaiLy);
                    lbTenDaiLy.Text    = dl.TenDaiLy;
                    lblMail.Text       = dl.MaDaiLy;
                    lbSoDienThoai.Text = dl.DienThoai;
                    lblDiaChi.Text     = dl.DiaChi;

                    btnLuuPT.Enabled   = false;
                    btnInPhieu.Enabled = true;
                }
                else
                {
                    //gán thông tin phiếu thu
                    txtTien.Text = "";
                    dTPK.Value   = DateTime.Today;
                    cmbMaDL.Text = "";
                    //gán thông tin đại lý

                    lbTenDaiLy.Text    = "";
                    lblMail.Text       = "";
                    lbSoDienThoai.Text = "";
                    lblDiaChi.Text     = "";
                    MessageBox.Show("Không Tìm Thấy Phiếu Thu", "Thông Báo");
                }
            }
            else
            {
                MessageBox.Show("Phải Điền Ma Phiếu Thu", "Thông Báo");
            }
        }
Пример #6
0
 //update
 public bool Update(string maPT, PHIEUTHUTIEN ptt)
 {
     using (QLDLDataContext db = new QLDLDataContext())
     {
         PHIEUTHUTIEN temp = db.PHIEUTHUTIENs.Where(p => p.MaPhieuThu == maPT).FirstOrDefault();
         temp.NgayThuTien = ptt.NgayThuTien;
         temp.SoTienThu   = ptt.SoTienThu;
         temp.MaDaiLy     = ptt.MaDaiLy;
         try
         {
             db.SubmitChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
Пример #7
0
        public bool InsertPhieuThu(PHIEUTHUTIEN pt)
        {
            try
            {
                using (QLDLEntities context = new QLDLEntities())
                {
                    DAILY daily = context.DAILies.FirstOrDefault(dl => dl.MADL == pt.MADL);
                    daily.SONO -= pt.SOTIEN;

                    context.PHIEUTHUTIENs.Add(pt);
                    context.SaveChanges();
                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
Пример #8
0
        private void btnSuaThuTien_Click(object sender, EventArgs e)
        {
            string       thutienID = txtMaThuTien.Text;
            PHIEUTHUTIEN thutien   = db.PHIEUTHUTIENs.Where(p => p.MaThuTien == thutienID).SingleOrDefault();

            if (thutien == null)
            {
                MessageBox.Show("Mã thu tiền không tồn tại");
                return;
            }
            if (thutien != null)
            {
                thutien.MaThuTien   = thutienID;
                thutien.NgayThuTien = DateTime.Parse(txtNgayThuTien.Text);
                thutien.SoTienThu   = int.Parse(txtSoTienThu.Text);
                thutien.TienConLai  = int.Parse(txtTienConLai.Text);
                db.SaveChanges();
                LoadDataThuTien();
                MessageBox.Show("Cập nhật phiếu thu tiền thành công");
            }
        }
Пример #9
0
        public MoneyCollectionViewVM()
        {
            Date       = DateTime.Today;
            AddCommand = new RelayCommand <Button>((p) => { return(SelectedCustomer != null && Collection != null && ID != null && Date != null ? true : false); }, (p) =>
            {
                var receiptNote = new PHIEUTHUTIEN()
                {
                    MAPT = ID, MAKH = CustomerID, TIENNO = Debt, TIENTHU = Collection, NGAYTHU = DateTime.Now
                };
                if (DataProvider.Ins.DB.PHIEUTHUTIENs.Where(x => x.MAPT == receiptNote.MAPT).Count() > 0)
                {
                    MessageBoxWindow mess2 = new MessageBoxWindow();
                    mess2.Tag = "Mã phiếu thu bị trùng";
                    mess2.ShowDialog();
                    //MessageBox.Show("Mã phiếu thu bị trùng", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    DataProvider.Ins.DB.PHIEUTHUTIENs.Add(receiptNote);
                    DataProvider.Ins.DB.SaveChanges();
                    ListMoneyCollection.Add(receiptNote);
                    DataProvider.Ins.DB.KHACHHANGs.Where(x => x.MAKH == SelectedCustomer.MAKH).SingleOrDefault().TIENNO = 0; // update
                    DataProvider.Ins.DB.SaveChanges();
                }
            });
            DeleteCommand = new RelayCommand <Button>((p) => { return(true); }, (p) =>
            {
                var receiptNote = DataProvider.Ins.DB.PHIEUTHUTIENs.Where(x => x.MAPT == SelectedItem.MAPT).SingleOrDefault();
                DataProvider.Ins.DB.PHIEUTHUTIENs.Remove(receiptNote);
                DataProvider.Ins.DB.SaveChanges();

                ListMoneyCollection.Remove(SelectedItem);
            });
            ListMoneyCollection = new ObservableCollection <PHIEUTHUTIEN>(DataProvider.Ins.DB.PHIEUTHUTIENs);
            ListCustomer        = new ObservableCollection <KHACHHANG>(DataProvider.Ins.DB.KHACHHANGs);
        }
Пример #10
0
 //Updadte
 public bool Update(string maPTT, PHIEUTHUTIEN ptt)
 {
     return(PhieuThuTienDAO.Instance.Update(maPTT, ptt));
 }