//Sửa
 public bool UpdateDUTOANCONGTRINH(DUTOANCONGTRINHmodel data)
 {
     SqlParameter[] sqlParameters = new SqlParameter[]
     {
         new SqlParameter("@DTCTID", data.DTCTID),
         new SqlParameter("@QLID", data.QLID),
         new SqlParameter("@ItemID", data.ItemID),
         new SqlParameter("@ItemUnitID", data.ItemUnitID),
         new SqlParameter("@ItemReplaceID", data.ItemReplaceID),
         new SqlParameter("@ItemUnitReplaceID", data.ItemUnitReplaceID),
         new SqlParameter("@MaVT", data.MaVT),
         new SqlParameter("@TenVT", data.TenVT),
         new SqlParameter("@SoLuong", data.SoLuong),
         new SqlParameter("@DonGia", data.DonGia),
         new SqlParameter("@ThanhTien", data.ThanhTien),
         new SqlParameter("@STTUuTien", data.STTUuTien),
         new SqlParameter("@SoLuongXuat", data.SoLuongXuat),
         new SqlParameter("@DonGiaXuat", data.DonGiaXuat),
         new SqlParameter("@ThanhTienXuat", data.ThanhTienXuat),
         new SqlParameter("@VouchersID", data.VouchersID),
         new SqlParameter("@WareHouseDetailID", data.WareHouseDetailID),
         new SqlParameter("@UserID", UserInfo.UserID),
         new SqlParameter("@CompanyID", CommonInfo.CompanyInfo.CompanyID),
     };
     this.Context.ExecuteDataFromProcedure("DUTOANCONGTRINHUpdate", sqlParameters);
     return(true);
 }
 //Xóa
 public bool DeleteDUTOANCONGTRINH(DUTOANCONGTRINHmodel data)
 {
     SqlParameter[] sqlParameters = new SqlParameter[]
     {
         new SqlParameter("@DTCTID", data.DTCTID),
         new SqlParameter("@UserID", UserInfo.UserID),
         new SqlParameter("@CompanyID", CommonInfo.CompanyInfo.CompanyID)
     };
     this.Context.ExecuteDataFromProcedure("DUTOANCONGTRINHDelete", sqlParameters);
     return(true);
 }
        public bool SaveWareHouseDetail(List <WareHouseDetail> saveData, string voucherID)
        {
            using (DbContextTransaction transaction = Context.Database.BeginTransaction())
            {
                try
                {
                    long seq = WareHouseDetailDAO.GetWareHouseDetailSEQ();
                    foreach (WareHouseDetail data in saveData)
                    {
                        switch (data.Status)
                        {
                        // Add new
                        case ModifyMode.Insert:
                            seq++;
                            data.WareHouseDetailID = GenerateID.WareHouseDetailID(seq);
                            this.WareHouseDetailDAO.InsertWareHouseDetail(data);
                            break;

                        // Update
                        case ModifyMode.Update:
                            this.WareHouseDetailDAO.UpdateWareHouseDetail(data);
                            break;

                        // Delete
                        case ModifyMode.Delete:
                            this.WareHouseDetailDAO.DeleteWareHouseDetail(data.WareHouseDetailID, data.CompanyID);
                            DUTOANCONGTRINHmodel itemDTCTModel = new DUTOANCONGTRINHmodel
                            {
                                DonGiaXuat        = 0,
                                SoLuongXuat       = 0,
                                ThanhTienXuat     = 0,
                                WareHouseDetailID = data.WareHouseDetailID,
                                VouchersID        = voucherID,
                                ItemID            = data.ItemID,
                                ItemUnitID        = data.ItemUnitID
                            };
                            this.DUTOANCONGTRINHDAO.EditDUTOANCONGTRINH(itemDTCTModel);
                            //update Dự Toán Công Trình
                            break;
                        }
                    }
                    transaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    BSLog.Logger.Error(ex.Message);
                    return(false);
                }
            }
        }
 private void SelectDTCTData()
 {
     int[] selectIndex = this.DTCT_gridView.GetSelectedRows();
     CommonInfo.DTCTDataSelected = new List <DUTOANCONGTRINHmodel>();
     foreach (int index in selectIndex)
     {
         DUTOANCONGTRINHmodel SelectDTCT = this.DTCT_gridView.GetRow(index) as DUTOANCONGTRINHmodel;
         if (!string.IsNullOrEmpty(SelectDTCT.DTCTID))
         {
             CommonInfo.DTCTDataSelected.Add(SelectDTCT);
         }
     }
     MessageBoxHelper.ShowInfoMessage("Lấy dữ liệu thành công!");
 }
 //Edit
 public bool EditDUTOANCONGTRINH(DUTOANCONGTRINHmodel data)
 {
     SqlParameter[] sqlParameters = new SqlParameter[]
     {
         new SqlParameter("@ItemID", data.ItemID),
         new SqlParameter("@ItemUnitID", data.ItemUnitID),
         new SqlParameter("@SoLuongXuat", data.SoLuongXuat),
         new SqlParameter("@DonGiaXuat", data.DonGiaXuat),
         new SqlParameter("@ThanhTienXuat", data.ThanhTienXuat),
         new SqlParameter("@VouchersID", data.VouchersID),
         new SqlParameter("@WareHouseDetailID", data.WareHouseDetailID),
         new SqlParameter("@UserID", UserInfo.UserID),
         new SqlParameter("@CompanyID", CommonInfo.CompanyInfo.CompanyID),
     };
     this.Context.ExecuteDataFromProcedure("DUTOANCONGTRINHEdit", sqlParameters);
     return(true);
 }
        private void DTCT_gridView_RowDeleted(object sender, DevExpress.Data.RowDeletedEventArgs e)
        {
            DUTOANCONGTRINHmodel delete = e.Row.CastTo <DUTOANCONGTRINHmodel>();

            if (delete.Status == ModifyMode.Insert)
            {
                return;
            }
            if (VoucherControl.CheckLockDBCompany(delete.QLNgayHopDong, CommonInfo.CompanyInfo.CompanyID))
            {
                //Dữ liệu đang nằm trong vùng khóa sổ
                MessageBoxHelper.ShowErrorMessage("Dữ liệu đang bị khóa sổ! Những dự toán nằm trong vùng khóa sổ sẽ không được xử lý");
                return;
            }
            delete.Status = ModifyMode.Delete;
            dtctDataDelete.Add(delete);
        }
Exemple #7
0
        public bool SaveWareHouseFull(WareHouse data, List <WareHouseDetail> detailData)
        {
            using (DbContextTransaction transaction = Context.Database.BeginTransaction())
            {
                try
                {
                    long seq       = WareHouseDAO.GetWareHouseSEQ();
                    long seqdetail = WareHouseDetailDAO.GetWareHouseDetailSEQ();
                    switch (data.Status)
                    {
                    // Thêm warehouse mới thì sẽ thực hiện thêm Detail mới nếu ListDetail có giá trị
                    case ModifyMode.Insert:
                        seq++;
                        data.WarehouseID = GenerateID.WareHouseID(seq);
                        this.WareHouseDAO.InsertWareHouse(data);
                        if (detailData.Count > 0)
                        {
                            //thêm warehouseDetail
                            #region insert warehouseDetail
                            foreach (WareHouseDetail wareHouseDetail in detailData)
                            {
                                if (wareHouseDetail.Status == ModifyMode.Insert)
                                {
                                    seqdetail++;
                                    wareHouseDetail.WareHouseDetailID = GenerateID.WareHouseDetailID(seqdetail);
                                    wareHouseDetail.WarehouseID       = data.WarehouseID;
                                    wareHouseDetail.VouchersID        = data.VouchersID;
                                    wareHouseDetail.CompanyID         = data.CompanyID;
                                    this.WareHouseDetailDAO.InsertWareHouseDetail(wareHouseDetail);
                                    //update Du Tonan Cong Trinh
                                    if (CommonInfo.DTCTDataSelected.Count > 0)
                                    {
                                        DUTOANCONGTRINHmodel itemDTCT = CommonInfo.DTCTDataSelected.Where(o => o.VouchersID == data.VouchersID &&
                                                                                                          o.ItemID == wareHouseDetail.ItemID).FirstOrDefault();
                                        if (itemDTCT != null)
                                        {
                                            itemDTCT.WareHouseDetailID = wareHouseDetail.WareHouseDetailID;
                                            //update DTCT
                                            DUTOANCONGTRINHDAO.UpdateDUTOANCONGTRINH(itemDTCT);
                                        }
                                    }
                                }
                            }
                            #endregion insert warehouseDetail
                        }
                        break;

                    //Khi update Warehouse thì sẽ thực hiện update WarehouseDetail, Thêm mới hoặc Warehouse Detail
                    case ModifyMode.Update:
                        this.WareHouseDAO.UpdateWareHouse(data);
                        if (detailData.Count > 0)
                        {
                            foreach (WareHouseDetail wareHouseDetail in detailData)
                            {
                                //thực hiện nhiệm vụ update với các chi tiết Warehouse đã thuộc warehouse
                                if (wareHouseDetail.Status == ModifyMode.Update)
                                {
                                    #region Update dataDetail
                                    if (!string.IsNullOrEmpty(wareHouseDetail.WareHouseDetailID))
                                    {
                                        this.WareHouseDetailDAO.UpdateWareHouseDetail(wareHouseDetail);
                                        DUTOANCONGTRINHmodel itemDTCT = new DUTOANCONGTRINHmodel
                                        {
                                            WareHouseDetailID = wareHouseDetail.WareHouseDetailID,
                                            VouchersID        = data.VouchersID,
                                            SoLuongXuat       = wareHouseDetail.Quantity,
                                            DonGiaXuat        = wareHouseDetail.Price,
                                            ThanhTienXuat     = wareHouseDetail.Amount,
                                            ItemID            = wareHouseDetail.ItemID,
                                            ItemUnitID        = wareHouseDetail.ItemUnitID,
                                        };
                                        //update DTCT
                                        DUTOANCONGTRINHDAO.EditDUTOANCONGTRINH(itemDTCT);
                                    }
                                    #endregion Update dataDetail
                                }
                                else if (wareHouseDetail.Status == ModifyMode.Insert)
                                {
                                    //thêm mới warehouseDetail vào warehouse
                                    #region insert warehouseDetail khi thêm detail mới cho warehouse đã có sẵn
                                    seqdetail++;
                                    wareHouseDetail.WareHouseDetailID = GenerateID.WareHouseDetailID(seqdetail);
                                    wareHouseDetail.WarehouseID       = data.WarehouseID;
                                    wareHouseDetail.VouchersID        = data.VouchersID;
                                    wareHouseDetail.CompanyID         = data.CompanyID;
                                    this.WareHouseDetailDAO.InsertWareHouseDetail(wareHouseDetail);
                                    #endregion insert warehouseDetail khi thêm detail mới cho warehouse đã có sẵn
                                }
                            }
                        }
                        break;

                    // Delete
                    case ModifyMode.Delete:
                        this.WareHouseDAO.DeleteWareHouse(data);
                        //Khi delete warehouse thì DB sẽ tự delete warehouse
                        break;

                    default:
                        //Khi warehouse không thực thêm, xóa, sửa thì có thể sẽ có thay đổi giá trị warehouseDetail
                        if (detailData.Count > 0)
                        {
                            foreach (WareHouseDetail wareHouseDetail in detailData)
                            {
                                //thực hiện nhiệm vụ update với các chi tiết warehouse đã thuộc warehouse
                                if (wareHouseDetail.Status == ModifyMode.Update)
                                {
                                    #region Update dataDetail
                                    if (!string.IsNullOrEmpty(wareHouseDetail.WareHouseDetailID))
                                    {
                                        this.WareHouseDetailDAO.UpdateWareHouseDetail(wareHouseDetail);
                                    }
                                    #endregion Update dataDetail
                                }
                                else if (wareHouseDetail.Status == ModifyMode.Insert)
                                {
                                    //thêm mới warehouseDetail vào warehouse
                                    #region insert warehouseDetail khi thêm detail mới cho warehouse đã có sẵn
                                    seqdetail++;
                                    wareHouseDetail.WareHouseDetailID = GenerateID.WareHouseDetailID(seqdetail);
                                    wareHouseDetail.WarehouseID       = data.WarehouseID;
                                    wareHouseDetail.VouchersID        = data.VouchersID;
                                    wareHouseDetail.CompanyID         = data.CompanyID;
                                    this.WareHouseDetailDAO.InsertWareHouseDetail(wareHouseDetail);
                                    #endregion insert warehouseDetail khi thêm detail mới cho warehouse đã có sẵn
                                }
                            }
                        }
                        break;
                    }
                    transaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    BSLog.Logger.Error(ex.Message);
                    return(false);
                }
            }
        }