Example #1
0
 private void Delete(int rowhandle)
 {
     if (grvList.RowCount > 0)
     {
         DeNghiXuatTieuHaoChiTietInfonew item = (DeNghiXuatTieuHaoChiTietInfonew)grvList.GetRow(grvList.FocusedRowHandle);
         listct.RemoveAt(listct.IndexOf(item));
     }
 }
 public void UpdateChiTietChungTu(DeNghiXuatTieuHaoChiTietInfonew chiTietChungTu)
 {
     ExecuteCommand(Declare.StoreProcedureNamespace.spChungTuChiTietXTHUpdate, chiTietChungTu.IdChungTuChiTiet,
                    chiTietChungTu.IdChungTu,
                    chiTietChungTu.IdSanPham,
                    chiTietChungTu.SoLuong,
                    chiTietChungTu.DonGia,
                    chiTietChungTu.Thanhtien);
 }
 private void Delete(int rowhandle)
 {
     if (grvList.RowCount > 0)
     {
         DeNghiXuatTieuHaoChiTietInfonew item = (DeNghiXuatTieuHaoChiTietInfonew)grvList.GetRow(rowhandle);
         business.ListChiTietChungTu.RemoveAt(business.ListChiTietChungTu.IndexOf(item));
         grcList.DataSource = null;
         grcList.DataSource = business.ListChiTietChungTu;
     }
 }
Example #4
0
 public int InsertChiTietChungTu(DeNghiXuatTieuHaoChiTietInfonew deNghiXuatTieuHaoChiTietInfo)
 {
     ExecuteCommand(Declare.StoreProcedureNamespace.spChungTuChiTietDNXTHNewInsert,
                    deNghiXuatTieuHaoChiTietInfo.IdChungTuChiTiet,
                    deNghiXuatTieuHaoChiTietInfo.IdChungTu,
                    deNghiXuatTieuHaoChiTietInfo.IdSanPham,
                    deNghiXuatTieuHaoChiTietInfo.SoLuong,
                    deNghiXuatTieuHaoChiTietInfo.DonGia,
                    deNghiXuatTieuHaoChiTietInfo.Thanhtien,
                    deNghiXuatTieuHaoChiTietInfo.IdChiPhi,
                    deNghiXuatTieuHaoChiTietInfo.IdPhongBan,
                    deNghiXuatTieuHaoChiTietInfo.Nganh);
     return(Convert.ToInt32(Parameters["p_IdChiTiet"].Value.ToString()));
 }
Example #5
0
 public void DeleteChiTietChungTu(DeNghiXuatTieuHaoChiTietInfonew deNghiXuatTieuHaoChiTietInfo)
 {
     ExecuteCommand(Declare.StoreProcedureNamespace.spCtCtDelByIdCtCt, deNghiXuatTieuHaoChiTietInfo.IdChungTuChiTiet);
 }
Example #6
0
        private void SaveAll()
        {
            try
            {
                List <DMChungTuNhapInfo> li = tblChungTuDataProvider.Search(txtSoPhieu.Text.Trim());
                if (li.Count > 0 && OID == 0)
                {
                    txtSoPhieu.Focus();
                    throw new ManagedException("Số phiếu đã tồn tại trong hệ thống.Xin hãy kiểm tra lại!");
                }
                //ConnectionUtil.Instance.BeginTransaction();
                SaveChungTu();
                for (int i = 0; i < opt.selection.Count; i++)
                {
                    DeNghiXuatTieuHaoChiTietInfonew dn = (DeNghiXuatTieuHaoChiTietInfonew)opt.selection[i];
                    business.ListChiTietChungTu.Add(dn);
                }

                frmProgress.Instance.Caption     = Text;
                frmProgress.Instance.Description = "Đang thực hiện ...";
                frmProgress.Instance.MaxValue    = 100;
                frmProgress.Instance.Value       = 0;

                frmProgress.Instance.DoWork(
                    delegate
                {
                    try
                    {
                        ConnectionUtil.Instance.BeginTransaction();

                        frmProgress.Instance.MaxValue = 10;

                        DeNghiNhapTieuHaoBusiness businessCloned = (DeNghiNhapTieuHaoBusiness)business.Clone();

                        frmProgress.Instance.Value += 1;

                        if (businessCloned.ChungTu.IdChungTu == 0 &&
                            !dteNgay.Enabled)
                        {
                            businessCloned.ChungTu.NgayLap = CommonProvider.Instance.GetSysDate();
                        }

                        frmProgress.Instance.Value += 1;

                        businessCloned.SaveChungTu();

                        frmProgress.Instance.Value += 1;

                        ConnectionUtil.Instance.CommitTransaction();

                        frmProgress.Instance.Description = "Đã xong!";

                        frmProgress.Instance.Value = frmProgress.Instance.MaxValue;

                        frmProgress.Instance.IsCompleted = true;
                    }
                    catch (Exception ex)
                    {
                        ConnectionUtil.Instance.RollbackTransaction();

                        MessageBox.Show(ex.Message);

                        frmProgress.Instance.Description = "Giao dịch không thành công!";

                        frmProgress.Instance.Value = frmProgress.Instance.MaxValue;

                        frmProgress.Instance.IsCompleted = true;

                        if (!(ex is ManagedException))
                        {
                            EventLogProvider.Instance.WriteOfflineLog(ex.ToString(), "Đề nghị nhập tiêu hao");
                        }
                    }
                });

                //ConnectionUtil.Instance.DoSerializableWorkInTransaction(
                //    delegate
                //        {
                //            frmProgress.Instance.MaxValue = 10;

                //            DeNghiNhapTieuHaoBusiness businessCloned = (DeNghiNhapTieuHaoBusiness)business.Clone();

                //            frmProgress.Instance.Value += 1;

                //            if (businessCloned.ChungTu.IdChungTu == 0 &&
                //                !dteNgay.Enabled) businessCloned.ChungTu.NgayLap = CommonProvider.Instance.GetSysDate();

                //            frmProgress.Instance.Value += 1;

                //            businessCloned.SaveChungTu();

                //            frmProgress.Instance.Value += 1;

                //        });
                ////ConnectionUtil.Instance.CommitTransaction();
            }
            catch (Exception)
            {
                //ConnectionUtil.Instance.RollbackTransaction();
                throw;
            }
        }
Example #7
0
        private bool Check()
        {
            if (grvList.RowCount <= 0)
            {
                throw new ManagedException("Bạn chưa thêm sản phẩm!");
            }
            if (Equals(bteTrungTam.Tag, null))
            {
                throw new ManagedException("Bạn chưa chọn trung tâm !");
            }
            if (Equals(bteKho.Tag, null))
            {
                throw new ManagedException("Bạn chưa chọn kho !");
            }
            if (Equals(bteTVDN.Tag, null))
            {
                throw new ManagedException("Bạn chưa chọn thương viên!");
            }
            if (Equals(bteNguoiQuanLy.Tag, null))
            {
                throw new ManagedException("Bạn chưa chọn người quản lý!");
            }
            DeNghiXuatTieuHaoChiTietInfonew pt = business.ListChiTietChungTu.Find(delegate(DeNghiXuatTieuHaoChiTietInfonew match)
            {
                return(match.IdSanPham == 0);
            });

            if (pt != null)
            {
                business.ListChiTietChungTu.Remove(pt);
            }
            for (int i = 0; i < opt.selection.Count; i++)
            {
                DeNghiXuatTieuHaoChiTietInfonew dn = (DeNghiXuatTieuHaoChiTietInfonew)opt.selection[i];
                //business.ListChiTietChungTu.Add(dn);
                if (dn.SoLuong <= 0)
                {
                    throw new ManagedException("Số lượng nhập lại phải lớn hơn 0!");
                }
            }
            business.ListChiTietChungTu.ForEach(delegate(DeNghiXuatTieuHaoChiTietInfonew ap)
            {
                if (ap.SoLuong <= 0)
                {
                    throw new ManagedException("Số lượng phải lớn hơn 0 !");
                }
            });
            business.ListChiTietChungTu.ForEach(delegate(DeNghiXuatTieuHaoChiTietInfonew ap)
            {
                if (ap.IdChiPhi == 0 || ap.IdPhongBan == 0)
                {
                    throw new ManagedException("Bạn chưa chọn phòng ban , chi phí!");
                }
            });
            business.ListChiTietChungTu.ForEach(delegate(DeNghiXuatTieuHaoChiTietInfonew ap)
            {
                if (ap.Nganh != null && ap.Nganh.Length > 2)
                {
                    throw new ManagedException("Bạn chưa chọn ngành!");
                }
            });
            business.ListChiTietChungTu.ForEach(delegate(DeNghiXuatTieuHaoChiTietInfonew itm)
            {
                if (business.ListChiTietChungTu.FindAll(
                        delegate(DeNghiXuatTieuHaoChiTietInfonew math)
                {
                    return
                    (math.IdSanPham ==
                     itm.IdSanPham &&
                     math.IdChiPhi == itm.IdChiPhi &&
                     math.IdPhongBan == itm.IdPhongBan);
                }).Count > 1)
                {
                    throw new ManagedException("Mã sản phẩm - Phòng ban - Chi Phí bị lặp!");
                }
            });
            return(true);
        }