Example #1
0
        public ActionResult _FilterPost(JobOrderLineFilterViewModel vm)
        {
            if (vm.JobOrderSettings.isVisibleRate && vm.JobOrderSettings.isMandatoryRate && (vm.Rate == null || vm.Rate == 0))
            {
                ModelState.AddModelError("", "Rate is mandatory");
                PrepareViewBag(null);
                return(PartialView("_Filters", vm));
            }


            List <JobOrderLineViewModel> temp = _JobOrderLineService.GetProdOrdersForFilters(vm).ToList();

            bool UnitConvetsionException = (from p in temp
                                            where p.UnitConversionException == true
                                            select p).Any();

            if (UnitConvetsionException)
            {
                ModelState.AddModelError("", "Unit Conversion are missing for few Products");
            }

            JobOrderMasterDetailModel svm = new JobOrderMasterDetailModel();

            svm.JobOrderLineViewModel = temp;

            JobOrderHeader Header = _jobOrderHeaderService.Find(vm.JobOrderHeaderId);

            JobOrderSettings Settings = _jobOrderSettingsService.GetJobOrderSettingsForDocument(Header.DocTypeId, Header.DivisionId, Header.SiteId);

            svm.JobOrderSettings = Mapper.Map <JobOrderSettings, JobOrderSettingsViewModel>(Settings);

            return(PartialView("_Results", svm));
        }
Example #2
0
        private void GetChanges(ApplicationDbContext con, JobOrderSettings settings)
        {
            var Entry = con.Entry <JobOrderSettings>(settings);

            var PropNames = Entry.CurrentValues.PropertyNames;

            var ModifiedRecords = (from name in PropNames
                                   where Entry.Property(name).IsModified
                                   select name).ToList();
        }
Example #3
0
        public ActionResult Post(JobOrderSettingsViewModel vm)
        {
            JobOrderSettings pt = AutoMapper.Mapper.Map <JobOrderSettingsViewModel, JobOrderSettings>(vm);

            if (vm.ProcessId <= 0)
            {
                ModelState.AddModelError("ProcessId", "The Process field is required");
            }

            if (vm.MaxDays.HasValue && vm.DueDays > vm.MaxDays.Value)
            {
                ModelState.AddModelError("DueDays", "DueDays Exceeding MaxDueDays");
            }


            if (ModelState.IsValid)
            {
                if (vm.JobOrderSettingsId <= 0)
                {
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _JobOrderSettingsService.Create(pt);

                    try
                    {
                        _unitOfWork.Save();
                    }
                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        PrepareViewBag(vm.DocTypeId);
                        return(View("Create", vm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = pt.DocTypeId,
                        DocId        = pt.JobOrderSettingsId,
                        ActivityType = (int)ActivityTypeContants.SettingsAdded,
                    }));

                    return(RedirectToAction("Index", "JobOrderHeader", new { id = vm.DocTypeId }).Success("Data saved successfully"));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    JobOrderSettings temp = db.JobOrderSettings.Find(pt.JobOrderSettingsId);

                    JobOrderSettings ExRec = Mapper.Map <JobOrderSettings>(temp);

                    temp.filterContraDocTypes      = pt.filterContraDocTypes;
                    temp.filterLedgerAccountGroups = pt.filterLedgerAccountGroups;
                    temp.filterLedgerAccounts      = pt.filterLedgerAccounts;
                    temp.ProcessId               = pt.ProcessId;
                    temp.filterProductGroups     = pt.filterProductGroups;
                    temp.filterProducts          = pt.filterProducts;
                    temp.filterProductCategories = pt.filterProductCategories;
                    temp.filterProductTypes      = pt.filterProductTypes;
                    temp.SqlProcGatePass         = pt.SqlProcGatePass;
                    temp.BarcodeStatusUpdate     = pt.BarcodeStatusUpdate;
                    temp.isEditableRate          = pt.isEditableRate;
                    temp.NonCountedQty           = pt.NonCountedQty;
                    temp.isVisibleFromProdOrder  = pt.isVisibleFromProdOrder;
                    temp.LossQty                   = pt.LossQty;
                    temp.JobUnitId                 = pt.JobUnitId;
                    temp.DealUnitId                = pt.DealUnitId;
                    temp.WizardMenuId              = pt.WizardMenuId;
                    temp.ImportMenuId              = pt.ImportMenuId;
                    temp.isMandatoryGodown         = pt.isMandatoryGodown;
                    temp.isVisibleGodown           = pt.isVisibleGodown;
                    temp.isMandatoryCostCenter     = pt.isMandatoryCostCenter;
                    temp.isMandatoryMachine        = pt.isMandatoryMachine;
                    temp.isMandatoryProcessLine    = pt.isMandatoryProcessLine;
                    temp.isMandatoryRate           = pt.isMandatoryRate;
                    temp.isMandatoryProductUID     = pt.isMandatoryProductUID;
                    temp.CalculationId             = pt.CalculationId;
                    temp.ExcessQtyAllowedPer       = pt.ExcessQtyAllowedPer;
                    temp.isUniqueCostCenter        = pt.isUniqueCostCenter;
                    temp.PersonWiseCostCenter      = pt.PersonWiseCostCenter;
                    temp.SqlProcGenProductUID      = pt.SqlProcGenProductUID;
                    temp.SqlProcProductUidHelpList = pt.SqlProcProductUidHelpList;
                    temp.Perks = pt.Perks;
                    temp.filterContraDivisions  = pt.filterContraDivisions;
                    temp.isVisibleProcessLine   = pt.isVisibleProcessLine;
                    temp.isVisibleProcessHeader = pt.isVisibleProcessHeader;
                    temp.DueDays                    = pt.DueDays;
                    temp.filterContraSites          = pt.filterContraSites;
                    temp.filterPersonRoles          = pt.filterPersonRoles;
                    temp.isPostedInStock            = pt.isPostedInStock;
                    temp.isVisibleUncountableQty    = pt.isVisibleUncountableQty;
                    temp.isVisibleLoss              = pt.isVisibleLoss;
                    temp.UnitConversionForId        = pt.UnitConversionForId;
                    temp.SqlProcConsumption         = pt.SqlProcConsumption;
                    temp.isPostedInStockProcess     = pt.isPostedInStockProcess;
                    temp.isPostedInStockVirtual     = pt.isPostedInStockVirtual;
                    temp.isVisibleCostCenter        = pt.isVisibleCostCenter;
                    temp.isVisibleDimension1        = pt.isVisibleDimension1;
                    temp.isVisibleDimension2        = pt.isVisibleDimension2;
                    temp.isVisibleDimension3        = pt.isVisibleDimension3;
                    temp.isVisibleDimension4        = pt.isVisibleDimension4;
                    temp.isVisibleDiscountPer       = pt.isVisibleDiscountPer;
                    temp.isVisibleLotNo             = pt.isVisibleLotNo;
                    temp.isVisibleMachine           = pt.isVisibleMachine;
                    temp.isVisibleProductUID        = pt.isVisibleProductUID;
                    temp.isVisibleStockIn           = pt.isVisibleStockIn;
                    temp.isVisibleRate              = pt.isVisibleRate;
                    temp.isVisibleDealUnit          = pt.isVisibleDealUnit;
                    temp.isVisibleLineDueDate       = pt.isVisibleLineDueDate;
                    temp.isVisibleBillToParty       = pt.isVisibleBillToParty;
                    temp.isVisibleUnitConversionFor = pt.isVisibleUnitConversionFor;
                    temp.isVisibleSpecification     = pt.isVisibleSpecification;
                    temp.isVisibleCreditDays        = pt.isVisibleCreditDays;


                    temp.CalculateDiscountOnRate = pt.CalculateDiscountOnRate;


                    temp.isVisibleFinancier      = pt.isVisibleFinancier;
                    temp.isVisibleSalesExecutive = pt.isVisibleSalesExecutive;

                    temp.isVisibleDeliveryTerms        = pt.isVisibleDeliveryTerms;
                    temp.isVisibleShipToAddress        = pt.isVisibleShipToAddress;
                    temp.isVisibleCurrency             = pt.isVisibleCurrency;
                    temp.isVisibleSalesTaxGroupPerson  = pt.isVisibleSalesTaxGroupPerson;
                    temp.isVisibleSalesTaxGroupProduct = pt.isVisibleSalesTaxGroupProduct;
                    temp.isVisibleShipMethod           = pt.isVisibleShipMethod;
                    temp.isVisibleDocumentShipMethod   = pt.isVisibleDocumentShipMethod;
                    temp.isVisibleTransporter          = pt.isVisibleTransporter;
                    temp.isVisibleAgent        = pt.isVisibleAgent;
                    temp.isVisibleDoorDelivery = pt.isVisibleDoorDelivery;
                    temp.isVisiblePaymentTerms = pt.isVisiblePaymentTerms;

                    temp.NonCountedQtyCaption = pt.NonCountedQtyCaption;
                    temp.SqlProcDocumentPrint = pt.SqlProcDocumentPrint;
                    temp.DocumentPrint        = pt.DocumentPrint;
                    temp.MaxDays                     = pt.MaxDays;
                    temp.AmountRoundOff              = pt.AmountRoundOff;
                    temp.NoOfPrintCopies             = pt.NoOfPrintCopies;
                    temp.DocumentPrintReportHeaderId = pt.DocumentPrintReportHeaderId;
                    temp.ModifiedDate                = DateTime.Now;
                    temp.ModifiedBy                  = User.Identity.Name;
                    temp.ObjectState                 = Model.ObjectState.Modified;

                    GetChanges(db, temp);


                    _JobOrderSettingsService.Update(temp);

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });

                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        PrepareViewBag(vm.DocTypeId);
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = temp.DocTypeId,
                        DocId           = temp.JobOrderSettingsId,
                        ActivityType    = (int)ActivityTypeContants.SettingsModified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index", "JobOrderHeader", new { id = vm.DocTypeId }).Success("Data saved successfully"));
                }
            }
            PrepareViewBag(vm.DocTypeId);
            return(View("Create", vm));
        }
Example #4
0
 public void Update(JobOrderSettings pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <JobOrderSettings>().Update(pt);
 }
Example #5
0
 public void Delete(JobOrderSettings pt)
 {
     _unitOfWork.Repository <JobOrderSettings>().Delete(pt);
 }
Example #6
0
 public JobOrderSettings Create(JobOrderSettings pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <JobOrderSettings>().Insert(pt);
     return(pt);
 }
Example #7
0
 public JobOrderSettings Add(JobOrderSettings pt)
 {
     _unitOfWork.Repository <JobOrderSettings>().Insert(pt);
     return(pt);
 }