コード例 #1
0
        //Lưu sản phẩm nhập
        private void btnLuuNhap_Click(object sender, EventArgs e)
        {
            Decimal      TotalMoney = 0;
            DialogResult dlr        = Decimal.Parse(txtTotaltoEdit.Text) > 0 ? MessageBox.Show("Bạn có muốn thay đổi chi tiết phiếu ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk)
                : MessageBox.Show("Bạn có muốn lưu không? ", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);

            if (dlr == DialogResult.Yes)
            {
                for (int row = 0; row < dgvDetailIn.Rows.Count; row++)
                {
                    String       IDProduct      = dgvDetailIn.Rows[row].Cells[0].Value.ToString();
                    Decimal      Price          = decimal.Parse(dgvDetailIn.Rows[row].Cells[3].Value.ToString());
                    int          Quality        = int.Parse(dgvDetailIn.Rows[row].Cells[2].Value.ToString());
                    ChiTietPhieu coupondetailto = getCouponDetail(txtIDCouponDetailIn.Text, IDProduct, Price, Quality);
                    if (_service.getDetailCoupon(txtIDCouponDetailIn.Text, IDProduct) == null)
                    {
                        _service.CreateDetailCoupon(coupondetailto);
                    }
                    else
                    {
                        _service.UpdateDetailCoupon(coupondetailto);
                    }
                    TotalMoney += Price * Quality;
                }
                PhieuNhapXuat Target = _service.getCoupon(txtIDCouponDetailIn.Text);
                Target.TongTien = TotalMoney;
                _service.EditCoupon(Target);
                View();
            }
        }
コード例 #2
0
 public bool CreateDetailCoupon(ChiTietPhieu DetailCouponToCreate)
 {
     //            if (!ValidateDetailCoupon(DetailCouponToCreate))
     //   return false;
     try
     {
         _detailCouponrepository.createDetailCoupon(DetailCouponToCreate);
         SanPham       product = _productrepository.GetProduct(DetailCouponToCreate.MaSP);
         Kho           target  = getWareHouse(DetailCouponToCreate.MaSP);
         PhieuNhapXuat Phieu   = getCoupon(DetailCouponToCreate.MaPhieu);
         if (Phieu.TrangThai.Equals("Nhập"))
         {
             target.SoLuong = target.SoLuong + DetailCouponToCreate.SoLuong;
             target.NgayLap = Phieu.NgayLap;
         }
         else
         {
             target.SoLuong  = target.SoLuong - DetailCouponToCreate.SoLuong;
             product.SoLuong = product.SoLuong + DetailCouponToCreate.SoLuong;
             target.NgayXuat = Phieu.NgayLap;
             _productrepository.EditProduct(product);
         }
         _warehouserepository.UpdateWareHouse(target);
     }
     catch
     {
         return(false);
     }
     return(true);
 }
コード例 #3
0
 public bool UpdateDetailCoupon(ChiTietPhieu DetailCouponToEdit)
 {
     try
     {
         SanPham       product = _productrepository.GetProduct(DetailCouponToEdit.MaSP);
         Kho           target  = getWareHouse(DetailCouponToEdit.MaSP);
         PhieuNhapXuat Phieu   = getCoupon(DetailCouponToEdit.MaPhieu);
         ChiTietPhieu  chitiet = getDetailCoupon(DetailCouponToEdit.MaPhieu, DetailCouponToEdit.MaSP);
         if (Phieu.TrangThai.Equals("Nhập"))
         {
             target.SoLuong = target.SoLuong - chitiet.SoLuong + DetailCouponToEdit.SoLuong;
             target.NgayLap = Phieu.NgayLap;
         }
         else
         {
             target.SoLuong  = target.SoLuong + chitiet.SoLuong - DetailCouponToEdit.SoLuong;
             product.SoLuong = product.SoLuong - chitiet.SoLuong + DetailCouponToEdit.SoLuong;
             target.NgayXuat = Phieu.NgayLap;
             _productrepository.EditProduct(product);
         }
         _warehouserepository.UpdateWareHouse(target);
     }
     catch { return(false); }
     _detailCouponrepository.editDetailCoupon(DetailCouponToEdit);
     return(true);
 }
コード例 #4
0
        public PhieuNhapXuat EditCoupon(PhieuNhapXuat CouponToEdit)
        {
            var originalCoupon = GetCoupon(CouponToEdit.MaPhieu);

            _entities.Entry(originalCoupon).CurrentValues.SetValues(CouponToEdit);

            _entities.SaveChanges();
            return(CouponToEdit);
        }
コード例 #5
0
 //Thêm
 private void btnAddCounpon_Click(object sender, EventArgs e)
 {
     //Tự tạo 1 phiếu mới dựa <tự động>
     target = _service.createNewCoupon();
     txtIDCoupontoEdit.Text   = target.MaPhieu;
     txtIDEmployeetoEdit.Text = target.MaNV;
     txtTotaltoEdit.Text      = target.TongTien.ToString();
     txtDatetoEdit.Text       = target.NgayLap.ToString();
     EnabledButtonCoupon(true);
 }
コード例 #6
0
 public bool DeleteCoupon(PhieuNhapXuat couponToDelete)
 {
     try
     {
         _couponrepository.DeleteCoupon(couponToDelete);
     }
     catch
     {
         return(false);
     }
     return(true);
 }
コード例 #7
0
 public bool CreateCoupon(PhieuNhapXuat couponToCreate)
 {
     //Kiểm tra logic
     //Kiểm tra database
     try
     {
         _couponrepository.CreateCoupon(couponToCreate);
     }
     catch
     {
         return(false);
     }
     return(true);
 }
コード例 #8
0
 public bool EditCoupon(PhieuNhapXuat couponToEdit)
 {
     //Kiểm tra logic
     //kiểm tra database
     try
     {
         _couponrepository.EditCoupon(couponToEdit);
     }
     catch
     {
         return(false);
     }
     return(true);
 }
コード例 #9
0
        //Thêm chi tiet phiếu - Xuất dữ liệu
        private void btnSaveOfDetailOut_Click(object sender, EventArgs e)
        {
            int          flag       = 0;
            Decimal      TotalMoney = 0;
            DialogResult dlr        = Decimal.Parse(txtTotaltoEdit.Text) > 0 ? MessageBox.Show("Bạn có muốn thay đổi chi tiết phiếu ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk)
                : MessageBox.Show("Bạn có muốn lưu không? ", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk);

            if (dlr == DialogResult.Yes)
            {
                for (int row = 0; row < dgvDetailOut.Rows.Count; row++)
                {
                    String       IDProduct      = dgvDetailOut.Rows[row].Cells[0].Value.ToString();
                    Decimal      Price          = decimal.Parse(dgvDetailOut.Rows[row].Cells[3].Value.ToString());
                    int          Quality        = int.Parse(dgvDetailOut.Rows[row].Cells[2].Value.ToString());
                    ChiTietPhieu coupondetailto = getCouponDetail(txtIDCouponDetailOut.Text, IDProduct, Price, Quality);
                    if (_service.getDetailCoupon(txtIDCouponDetailOut.Text, IDProduct) == null)
                    {
                        if (!_service.CreateDetailCoupon(coupondetailto))
                        {
                            flag = 1;
                        }
                        MessageBox.Show("1");
                    }
                    else
                    {
                        if (!_service.UpdateDetailCoupon(coupondetailto))
                        {
                            flag = 1;
                        }
                        MessageBox.Show("2");
                    }
                    TotalMoney += Price * Quality;
                }
                if (flag == 0)
                {
                    PhieuNhapXuat Target = _service.getCoupon(txtIDCouponDetailOut.Text);
                    Target.TongTien = TotalMoney;
                    _service.EditCoupon(Target);
                    View();
                }
                else
                {
                    MessageBox.Show("Lỗi: Hệ thống đang bận vui lòng thử lại sau", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #10
0
        //Xóa phiếu
        private void btnXoa_Click(object sender, EventArgs e)
        {
            target = _service.getCoupon(txtIDCoupontoEdit.Text);
            DialogResult dlr = MessageBox.Show("Bạn có muốn xóa phiếu ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dlr == DialogResult.Yes)
            {
                if (_service.DeleteCoupon(target))
                {
                    MessageBox.Show("Đã xóa", "Thông báo ");
                    View();
                }
                else
                {
                    MessageBox.Show("Đã xảy ra lỗi", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #11
0
        public PhieuNhapXuat createNewCoupon()
        {
            PhieuNhapXuat target = _couponrepository.ListCoupons().LastOrDefault();

            if (target != null)
            {
                int SoPhieu = int.Parse(target.MaPhieu.Substring(2));
                SoPhieu++;
                string newMaPhieu;
                if (SoPhieu < 10)
                {
                    newMaPhieu = "MP00" + SoPhieu.ToString();
                }
                else if (SoPhieu < 100)
                {
                    newMaPhieu = "MP0" + SoPhieu.ToString();
                }
                else
                {
                    newMaPhieu = "MP" + SoPhieu.ToString();
                }
                return(new PhieuNhapXuat()
                {
                    MaPhieu = newMaPhieu,
                    MaNV = Information.Nhanvien.MaNV,
                    NgayLap = DateTime.Now,
                    TongTien = 0,
                    TrangThai = null,
                });
            }
            else
            {
                return(new PhieuNhapXuat()
                {
                    MaPhieu = "MP001",
                    MaNV = Information.Nhanvien.MaNV,
                    NgayLap = DateTime.Now,
                    TongTien = 0,
                    TrangThai = null,
                });
            }
        }
コード例 #12
0
        //Cofirm tạo phiếu mới
        private void btnSaveofCoupon_Click(object sender, EventArgs e)
        {
            errProdive.Clear();
            PhieuNhapXuat editCoupon = _service.getCoupon(txtIDCoupontoEdit.Text);

            try
            {
                target.TrangThai = cboStatustoEdit.SelectedItem.ToString();
                if (_service.CreateCoupon(target))
                {
                    View();
                    dgvCoupon.CurrentCell = dgvCoupon[0, dgvCoupon.Rows.Count - 1];
                    dgvCoupon.Rows[dgvCoupon.Rows.Count - 1].Selected = true;
                }
                EnabledButtonCoupon(false);
            }
            catch
            {
                errProdive.SetError(cboStatustoEdit, "Vui lòng chọn dữ liệu hợp lệ ");
            }
        }
コード例 #13
0
 public void DeleteCoupon(PhieuNhapXuat CouponToDelete)
 {
     _entities.PhieuNhapXuats.Remove(GetCoupon(CouponToDelete.MaPhieu));
     _entities.SaveChanges();
 }
コード例 #14
0
 public PhieuNhapXuat CreateCoupon(PhieuNhapXuat CouponToCreate)
 {
     _entities.PhieuNhapXuats.Add(CouponToCreate);
     _entities.SaveChanges();
     return(CouponToCreate);
 }
コード例 #15
0
 public PhieuNhapXuat CreateCoupon(PhieuNhapXuat CouponToCreate)
 {
     throw new NotImplementedException();
 }
コード例 #16
0
 public void DeleteCoupon(PhieuNhapXuat CouponToDelete)
 {
     throw new NotImplementedException();
 }
コード例 #17
0
 public PhieuNhapXuat EditCoupon(PhieuNhapXuat CouponToEdit)
 {
     throw new NotImplementedException();
 }