コード例 #1
0
 public JsonResult Save(ProcurementMasterViewModel ProcurementMasterViewModel, ProcurementDetailsViewModel[] procurementDetailsViewModel)
 {
     if (Session["strUserId"] == null)
     {
         return(Json(new
         {
             redirectUrl = Url.Action("Login", "Account"),
             isRedirect = true
         }));
     }
     else
     {
         LoadSession();
         ProcurementServices.Create(ProcurementMasterViewModel, procurementDetailsViewModel, intStoreId, strUserName);
         return(Json(new { success = true }));
     }
 }
コード例 #2
0
        public void Create(ProcurementMasterViewModel ProcurementMasterViewModel, ProcurementDetailsViewModel[] procurementDetailsViewModel, int intStoreId, string strUserName)
        {
            ProcurementMaster ProcurementMaster = new ProcurementMaster();


            ProcurementMaster.DateOfPurchase       = ProcurementMasterViewModel.DateOfPurchase;
            ProcurementMaster.DateOfReceive        = ProcurementMasterViewModel.DateOfReceive;
            ProcurementMaster.PO_GRAND_TOTAL       = ProcurementMasterViewModel.PO_GRAND_TOTAL;
            ProcurementMaster.ProcurementTypeId    = ProcurementMasterViewModel.ProcurementTypeId;
            ProcurementMaster.SupplierCompanyId    = ProcurementMasterViewModel.SupplierCompanyId;
            ProcurementMaster.SubContractCompanyId = ProcurementMasterViewModel.SubContractCompanyId;
            if (intStoreId >= 1000 && intStoreId < 2000)
            {
                ProcurementMaster.StoreId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                ProcurementMaster.SubStoreId = intStoreId;
            }
            else if (intStoreId >= 3000 && intStoreId < 4000)
            {
                ProcurementMaster.SubSubStoreId = intStoreId;
            }
            else if (intStoreId >= 4000 && intStoreId < 5000)
            {
                ProcurementMaster.SubSubSubStoreId = intStoreId;
            }
            else if (intStoreId >= 5000 && intStoreId < 6000)
            {
                ProcurementMaster.SubSubSubSubStoreId = intStoreId;
            }
            ProcurementMaster.PurchasedBy_ProcureBy = 1;
            ProcurementMaster.CreateBy   = strUserName;
            ProcurementMaster.CreateDate = DateTime.Now;
            ProcurementMaster.UpdateBy   = strUserName;
            ProcurementMaster.UpdateDate = DateTime.Now;



            UnitOfWork.ProcurementMasterRepository.Insert(ProcurementMaster);
            UnitOfWork.Save();

            var Pohdid = ProcurementMaster.PO_HD_ID;

            foreach (var items in procurementDetailsViewModel)
            {
                var ProcurementDetails = new ProcurementDetails
                {
                    PO_HD_ID               = Pohdid,
                    DateOfExpired          = Convert.ToDateTime(items.DateOfExpired),
                    DateOfNextMaintainance = Convert.ToDateTime(items.DateOfNextMaintainance),
                    Barcode                = items.Barcode,
                    Item_Unique_Number     = items.Item_Unique_Number,
                    Chesis_Number          = items.Chesis_Number,
                    Engine_Number          = items.Engine_Number,
                    ItemId                 = items.ItemId,
                    CountryId              = items.CountryId,
                    Principle_id           = items.Principle_id,
                    ConditionOfItemId      = items.ConditionOfItemId,
                    WarrantyId             = items.WarrantyId,
                    PO_QTD                 = items.PO_QTD,
                    PO_Price               = items.PO_Price,
                    SO_Price               = items.SO_Price,
                    PO_SubTotal            = items.PO_SubTotal,
                    CategoryId             = items.CategoryId,
                    SubCategoryId          = items.SubCategoryId,
                    SubSubCategoryId       = items.SubSubCategoryId,
                    SubSubSubCategoryId    = items.SubSubSubCategoryId,
                    SubSubSubSubCategoryId = items.SubSubSubSubCategoryId,
                    BrandId                = items.BrandId,
                    ModelId                = items.ModelId,
                    UnitId                 = items.UnitId,
                    MethodId               = items.MethodId,
                    IsNew = items.IsNew,
                    IsHot = items.IsHot
                };

                UnitOfWork.ProcurementDetailsRepository.Insert(ProcurementDetails);
                UnitOfWork.Save();
            }

            InventoryMaster InventoryMaster = new InventoryMaster();

            InventoryMaster.PO_HD_ID             = Pohdid;
            InventoryMaster.DateOfPurchase       = ProcurementMasterViewModel.DateOfPurchase;
            InventoryMaster.DateOfReceive        = ProcurementMasterViewModel.DateOfReceive;
            InventoryMaster.PO_GRAND_TOTAL       = ProcurementMasterViewModel.PO_GRAND_TOTAL;
            InventoryMaster.ProcurementTypeId    = ProcurementMasterViewModel.ProcurementTypeId;
            InventoryMaster.SupplierCompanyId    = ProcurementMasterViewModel.SupplierCompanyId;
            InventoryMaster.SubContractCompanyId = ProcurementMasterViewModel.SubContractCompanyId;
            if (intStoreId >= 1000 && intStoreId < 2000)
            {
                InventoryMaster.StoreId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                InventoryMaster.SubStoreId = intStoreId;
            }
            else if (intStoreId >= 3000 && intStoreId < 4000)
            {
                InventoryMaster.SubSubStoreId = intStoreId;
            }
            else if (intStoreId >= 4000 && intStoreId < 5000)
            {
                InventoryMaster.SubSubSubStoreId = intStoreId;
            }
            else if (intStoreId >= 5000 && intStoreId < 6000)
            {
                InventoryMaster.SubSubSubSubStoreId = intStoreId;
            }
            InventoryMaster.PurchasedBy_ProcureBy = 1;
            InventoryMaster.CreateBy   = strUserName;
            InventoryMaster.CreateDate = DateTime.Now;
            InventoryMaster.UpdateBy   = strUserName;
            InventoryMaster.UpdateDate = DateTime.Now;



            UnitOfWork.InventoryMasterRepository.Insert(InventoryMaster);
            UnitOfWork.Save();



            var invId = InventoryMaster.Inv_HD_ID;


            foreach (var items in procurementDetailsViewModel)
            {
                InventoryDetail InventoryDetails = new InventoryDetail();

                InventoryDetails.Inv_HD_ID              = invId;
                InventoryDetails.DateOfExpired          = Convert.ToDateTime(items.DateOfExpired);
                InventoryDetails.DateOfNextMaintainance = Convert.ToDateTime(items.DateOfNextMaintainance);
                InventoryDetails.Barcode                = items.Barcode;
                InventoryDetails.Item_Unique_Number     = items.Item_Unique_Number;
                InventoryDetails.Chesis_Number          = items.Chesis_Number;
                InventoryDetails.Engine_Number          = items.Engine_Number;
                InventoryDetails.ItemId                 = items.ItemId;
                InventoryDetails.CountryId              = items.CountryId;
                InventoryDetails.Principle_id           = items.Principle_id;
                InventoryDetails.ConditionOfItemId      = items.ConditionOfItemId;
                InventoryDetails.WarrantyId             = items.WarrantyId;
                InventoryDetails.TransactionQty         = items.PO_QTD;
                InventoryDetails.PO_Price               = items.PO_Price;
                InventoryDetails.SO_Price               = items.SO_Price;
                InventoryDetails.PO_SubTotal            = items.PO_SubTotal;
                InventoryDetails.CategoryId             = items.CategoryId;
                InventoryDetails.SubCategoryId          = items.SubCategoryId;
                InventoryDetails.SubSubCategoryId       = items.SubSubCategoryId;
                InventoryDetails.SubSubSubCategoryId    = items.SubSubSubCategoryId;
                InventoryDetails.SubSubSubSubCategoryId = items.SubSubSubSubCategoryId;
                InventoryDetails.BrandId                = items.BrandId;
                InventoryDetails.ModelId                = items.ModelId;
                InventoryDetails.UnitId                 = items.UnitId;
                InventoryDetails.MethodId               = items.MethodId;
                InventoryDetails.AvailableQty           = items.PO_QTD;
                InventoryDetails.IsNew = items.IsNew;
                InventoryDetails.IsHot = items.IsHot;
                UnitOfWork.InventoryDetailRepository.Insert(InventoryDetails);
                UnitOfWork.Save();
            }
        }