Example #1
0
        // GET: /ProductMaster/Edit/5

        public ActionResult Edit(int id)
        {
            Dimension1          D1 = _Dimension1Service.Find(id);
            Dimension1ViewModel pt = Mapper.Map <Dimension1, Dimension1ViewModel>(D1);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            ViewBag.id   = pt.ProductTypeId;
            ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductTypeId ?? 0).ProductTypeName;


            if (pt.ProductTypeId != null)
            {
                var settings = new ProductTypeSettingsService(_unitOfWork).GetProductTypeSettingsForDocument((int)pt.ProductTypeId);

                if (settings == null && UserRoles.Contains("SysAdmin"))
                {
                    return(RedirectToAction("Create", "ProductTypeSettings", new { id = id }).Warning("Please create Product Type Settings"));
                }
                else if (settings == null && !UserRoles.Contains("SysAdmin"))
                {
                    return(View("~/Views/Shared/InValidSettings.cshtml"));
                }
                pt.ProductTypeSettings = Mapper.Map <ProductTypeSettings, ProductTypeSettingsViewModel>(settings);
            }

            return(View("Create", pt));
        }
Example #2
0
        // GET: /JobReceiveHeader/Create

        public ActionResult Create(int id)//DocumentTypeId
        {
            Dimension1 vm = new Dimension1();

            vm.DocTypeId     = Constants.DocumentTypeIdConstants.Dimension1;
            vm.ProductTypeId = id;
            vm.IsActive      = true;
            ViewBag.Mode     = "Add";
            return(View("Create", vm));
        }
Example #3
0
        // GET: /JobReceiveHeader/Edit/5
        private ActionResult Edit(int id, string IndexType)
        {
            Dimension1 pt = _Dimension1Service.Find(id);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Mode = "Edit";
            return(View("Create", pt));
        }
Example #4
0
        public ActionResult DeleteConfirmed(ReasonViewModel vm)
        {
            if (ModelState.IsValid)
            {
                //Commit the DB
                try
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    Dimension1 temp      = _Dimension1Service.Find(vm.id);
                    int        DocTypeId = (int)temp.DocTypeId;

                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = Mapper.Map <Dimension1>(temp),
                    });

                    XElement Modifications = _modificationCheck.CheckChanges(LogList);

                    _Dimension1Service.Delete(vm.id);

                    _logger.LogActivityDetail(logVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = DocTypeId,
                        DocId           = temp.Dimension1Id,
                        ActivityType    = (int)ActivityTypeContants.Deleted,
                        UserRemark      = vm.Reason,
                        DocNo           = temp.Dimension1Name,
                        xEModifications = Modifications,
                        DocDate         = temp.CreatedDate,
                    }));
                }


                catch (Exception ex)
                {
                    string message = _exception.HandleException(ex);
                    TempData["CSEXC"] += message;
                    return(PartialView("_Reason", vm));
                }



                return(Json(new { success = true }));
            }
            return(PartialView("_Reason", vm));
        }
Example #5
0
        // GET: /ProductMaster/Delete/5

        public ActionResult Delete(int id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Dimension1 Dimension1 = _Dimension1Service.Find(id);

            if (Dimension1 == null)
            {
                return(HttpNotFound());
            }

            ReasonViewModel vm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", vm));
        }
 public Dimension1 Create(Dimension1 pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <Dimension1>().Insert(pt);
     return(pt);
 }
 public Dimension1 Add(Dimension1 pt)
 {
     _unitOfWork.Repository <Dimension1>().Insert(pt);
     return(pt);
 }
Example #8
0
        public ActionResult Post(Dimension1 vm)
        {
            Dimension1 pt = vm;

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


                    try
                    {
                        _Dimension1Service.Create(pt);
                    }



                    catch (Exception ex)
                    {
                        ViewBag.Mode = "Add";
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", vm));
                    }


                    _logger.LogActivityDetail(logVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = Constants.DocumentTypeIdConstants.Dimension1,
                        DocId        = pt.Dimension1Id,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));


                    return(RedirectToAction("Create", new { id = vm.ProductTypeId }).Success("Data saved successfully"));
                }

                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    Dimension1 temp = _Dimension1Service.Find(pt.Dimension1Id);

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

                    temp.Dimension1Name = pt.Dimension1Name;
                    temp.IsActive       = pt.IsActive;
                    temp.ModifiedDate   = DateTime.Now;
                    temp.ModifiedBy     = User.Identity.Name;
                    temp.ObjectState    = Model.ObjectState.Modified;


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

                    XElement Modifications = _modificationCheck.CheckChanges(LogList);

                    try
                    {
                        _Dimension1Service.Update(temp);
                    }

                    catch (Exception ex)
                    {
                        ViewBag.Mode = "Edit";
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        return(View("Create", pt));
                    }

                    _logger.LogActivityDetail(logVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = Constants.DocumentTypeIdConstants.Dimension1,
                        DocId           = temp.Dimension1Id,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    return(RedirectToAction("Index", new { id = vm.ProductTypeId }).Success("Data saved successfully"));
                }
            }
            return(View("Create", vm));
        }
Example #9
0
        public IEnumerable <SaleQuotationLineViewModel> GetSaleEnquiriesForFilters(SaleQuotationLineFilterViewModel vm)
        {
            byte?UnitConvForId = new SaleQuotationHeaderService(_unitOfWork).Find(vm.SaleQuotationHeaderId).UnitConversionForId;

            var SaleQuotation = new SaleQuotationHeaderService(_unitOfWork).Find(vm.SaleQuotationHeaderId);

            var Settings = new SaleQuotationSettingsService(_unitOfWork).GetSaleQuotationSettingsForDocument(SaleQuotation.DocTypeId, SaleQuotation.DivisionId, SaleQuotation.SiteId);



            string[] ProductIdArr = null;
            if (!string.IsNullOrEmpty(vm.ProductId))
            {
                ProductIdArr = vm.ProductId.Split(",".ToCharArray());
            }
            else
            {
                ProductIdArr = new string[] { "NA" };
            }

            string[] SaleOrderIdArr = null;
            if (!string.IsNullOrEmpty(vm.SaleEnquiryHeaderId))
            {
                SaleOrderIdArr = vm.SaleEnquiryHeaderId.Split(",".ToCharArray());
            }
            else
            {
                SaleOrderIdArr = new string[] { "NA" };
            }

            string[] Dimension1 = null;
            if (!string.IsNullOrEmpty(vm.Dimension1Id))
            {
                Dimension1 = vm.Dimension1Id.Split(",".ToCharArray());
            }
            else
            {
                Dimension1 = new string[] { "NA" };
            }

            string[] Dimension2 = null;
            if (!string.IsNullOrEmpty(vm.Dimension2Id))
            {
                Dimension2 = vm.Dimension2Id.Split(",".ToCharArray());
            }
            else
            {
                Dimension2 = new string[] { "NA" };
            }


            string[] Dimension3 = null;
            if (!string.IsNullOrEmpty(vm.Dimension3Id))
            {
                Dimension3 = vm.Dimension3Id.Split(",".ToCharArray());
            }
            else
            {
                Dimension3 = new string[] { "NA" };
            }

            string[] Dimension4 = null;
            if (!string.IsNullOrEmpty(vm.Dimension4Id))
            {
                Dimension4 = vm.Dimension4Id.Split(",".ToCharArray());
            }
            else
            {
                Dimension4 = new string[] { "NA" };
            }

            string[] ProductGroupIdArr = null;
            if (!string.IsNullOrEmpty(vm.ProductGroupId))
            {
                ProductGroupIdArr = vm.ProductGroupId.Split(",".ToCharArray());
            }
            else
            {
                ProductGroupIdArr = new string[] { "NA" };
            }



            if (!string.IsNullOrEmpty(vm.DealUnitId))
            {
                Unit Dealunit = new UnitService(_unitOfWork).Find(vm.DealUnitId);

                var temp = (from p in db.ViewSaleEnquiryBalanceForQuotation
                            join t in db.SaleEnquiryHeader on p.SaleEnquiryHeaderId equals t.SaleEnquiryHeaderId into table
                            from tab in table.DefaultIfEmpty()
                            join product in db.Product on p.ProductId equals product.ProductId into table2
                            join t1 in db.SaleEnquiryLine on p.SaleEnquiryLineId equals t1.SaleEnquiryLineId into table1
                            from tab1 in table1.DefaultIfEmpty()
                            from tab2 in table2.DefaultIfEmpty()
                            join t3 in db.UnitConversion on new { p1 = p.ProductId, DU1 = vm.DealUnitId, U1 = UnitConvForId ?? 0 } equals new { p1 = t3.ProductId ?? 0, DU1 = t3.ToUnitId, U1 = t3.UnitConversionForId } into table3
                            join FP in db.FinishedProduct on p.ProductId equals FP.ProductId into tableFinishedProduct
                            from tabFinishedProduct in tableFinishedProduct.DefaultIfEmpty()
                            from tab3 in table3.DefaultIfEmpty()
                            where (string.IsNullOrEmpty(vm.ProductId) ? 1 == 1 : ProductIdArr.Contains(p.ProductId.ToString())) &&
                            (string.IsNullOrEmpty(vm.SaleEnquiryHeaderId) ? 1 == 1 : SaleOrderIdArr.Contains(p.SaleEnquiryHeaderId.ToString())) &&
                            (string.IsNullOrEmpty(vm.Dimension1Id) ? 1 == 1 : Dimension1.Contains(p.Dimension1Id.ToString())) &&
                            (string.IsNullOrEmpty(vm.Dimension2Id) ? 1 == 1 : Dimension2.Contains(p.Dimension2Id.ToString())) &&
                            (string.IsNullOrEmpty(vm.Dimension3Id) ? 1 == 1 : Dimension3.Contains(p.Dimension3Id.ToString())) &&
                            (string.IsNullOrEmpty(vm.Dimension4Id) ? 1 == 1 : Dimension4.Contains(p.Dimension4Id.ToString())) &&
                            (string.IsNullOrEmpty(vm.ProductGroupId) ? 1 == 1 : ProductGroupIdArr.Contains(tab2.ProductGroupId.ToString())) &&
                            p.BalanceQty > 0
                            orderby tab.DocDate, tab.DocNo
                            select new SaleQuotationLineViewModel
                {
                    Dimension1Name = tab1.Dimension1.Dimension1Name,
                    Dimension2Name = tab1.Dimension2.Dimension2Name,
                    Dimension3Name = tab1.Dimension3.Dimension3Name,
                    Dimension4Name = tab1.Dimension4.Dimension4Name,
                    Dimension1Id = p.Dimension1Id,
                    Dimension2Id = p.Dimension2Id,
                    Dimension3Id = p.Dimension3Id,
                    Dimension4Id = p.Dimension4Id,
                    Specification = tab1.Specification,
                    SaleEnquiryBalanceQty = p.BalanceQty,
                    Qty = p.BalanceQty,
                    Rate = vm.Rate,
                    ProductName = tab2.ProductName,
                    ProductId = p.ProductId,
                    SaleQuotationHeaderId = vm.SaleQuotationHeaderId,
                    SaleEnquiryLineId = p.SaleEnquiryLineId,
                    UnitId = tab2.UnitId,
                    SaleEnquiryDocNo = p.SaleEnquiryNo,
                    DealUnitId = (vm.DealUnitId),
                    UnitConversionMultiplier = Math.Round((tab3 == null ? 1 : tab3.ToQty / tab3.FromQty), (tab3 == null ? tab2.Unit.DecimalPlaces : Dealunit.DecimalPlaces)),
                    UnitDecimalPlaces = tab2.Unit.DecimalPlaces,
                    DealUnitDecimalPlaces = (tab3 == null ? tab2.Unit.DecimalPlaces : Dealunit.DecimalPlaces)
                });
                return(temp);
            }
            else
            {
                var temp = (from p in db.ViewSaleEnquiryBalanceForQuotation
                            join t in db.SaleEnquiryHeader on p.SaleEnquiryHeaderId equals t.SaleEnquiryHeaderId into table
                            from tab in table.DefaultIfEmpty()
                            join product in db.Product on p.ProductId equals product.ProductId into table2
                            join t1 in db.SaleEnquiryLine on p.SaleEnquiryLineId equals t1.SaleEnquiryLineId into table1
                            from tab1 in table1.DefaultIfEmpty()
                            from tab2 in table2.DefaultIfEmpty()
                            join FP in db.FinishedProduct on p.ProductId equals FP.ProductId into tableFinishedProduct
                            from tabFinishedProduct in tableFinishedProduct.DefaultIfEmpty()
                            where (string.IsNullOrEmpty(vm.ProductId) ? 1 == 1 : ProductIdArr.Contains(p.ProductId.ToString())) &&
                            (string.IsNullOrEmpty(vm.SaleEnquiryHeaderId) ? 1 == 1 : SaleOrderIdArr.Contains(p.SaleEnquiryHeaderId.ToString())) &&
                            (string.IsNullOrEmpty(vm.Dimension1Id) ? 1 == 1 : Dimension1.Contains(p.Dimension1Id.ToString())) &&
                            (string.IsNullOrEmpty(vm.Dimension2Id) ? 1 == 1 : Dimension2.Contains(p.Dimension2Id.ToString())) &&
                            (string.IsNullOrEmpty(vm.Dimension3Id) ? 1 == 1 : Dimension3.Contains(p.Dimension3Id.ToString())) &&
                            (string.IsNullOrEmpty(vm.Dimension4Id) ? 1 == 1 : Dimension4.Contains(p.Dimension4Id.ToString())) &&
                            (string.IsNullOrEmpty(vm.ProductGroupId) ? 1 == 1 : ProductGroupIdArr.Contains(tab2.ProductGroupId.ToString())) &&
                            p.BalanceQty > 0
                            select new SaleQuotationLineViewModel
                {
                    Dimension1Name = tab1.Dimension1.Dimension1Name,
                    Dimension1Id = p.Dimension1Id,
                    Dimension2Name = tab1.Dimension2.Dimension2Name,
                    Dimension2Id = p.Dimension2Id,
                    Dimension3Name = tab1.Dimension3.Dimension3Name,
                    Dimension3Id = p.Dimension3Id,
                    Dimension4Name = tab1.Dimension4.Dimension4Name,
                    Dimension4Id = p.Dimension4Id,
                    Specification = tab1.Specification,
                    SaleEnquiryBalanceQty = p.BalanceQty,
                    Qty = p.BalanceQty,
                    Rate = vm.Rate,
                    SaleEnquiryDocNo = tab.DocNo,
                    ProductName = tab2.ProductName,
                    ProductId = p.ProductId,
                    SaleQuotationHeaderId = vm.SaleQuotationHeaderId,
                    SaleEnquiryLineId = p.SaleEnquiryLineId,
                    UnitId = tab2.UnitId,
                    DealUnitId = tab2.UnitId,
                    UnitConversionMultiplier = 1,
                    UnitDecimalPlaces = tab2.Unit.DecimalPlaces,
                    DealUnitDecimalPlaces = tab2.Unit.DecimalPlaces,
                }

                            );
                return(temp);
            }
        }
 public Dimension1 Create(Dimension1 pt)
 {
     pt.ObjectState = ObjectState.Added;
     _Dimension1Repository.Insert(pt);
     return(pt);
 }
 public void Update(Dimension1 pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _Dimension1Repository.Update(pt);
 }
 public void Delete(Dimension1 pt)
 {
     _Dimension1Repository.Delete(pt);
 }
Example #13
0
 public IEnumerable <EpsgAxisSet> ReadAllValues()
 {
     return(Dimension1.ReadAllValues()
            .Concat(Dimension2.ReadAllValues())
            .Concat(Dimension3.ReadAllValues()));
 }
Example #14
0
 public EpsgAxisSet GetSetByCsKey(ushort key)
 {
     return(Dimension2.GetByKey(key)
            ?? Dimension3.GetByKey(key)
            ?? Dimension1.GetByKey(key));
 }
Example #15
0
        public ActionResult Post(Dimension1ViewModel vm)
        {
            Dimension1 pt = Mapper.Map <Dimension1ViewModel, Dimension1>(vm);

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


                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        ViewBag.id   = vm.ProductTypeId;
                        ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId ?? 0).ProductTypeName;
                        return(View("Create", vm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.Dimension1).DocumentTypeId,
                        DocId        = pt.Dimension1Id,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

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

                    Dimension1 temp  = _Dimension1Service.Find(pt.Dimension1Id);
                    Dimension1 ExRec = Mapper.Map <Dimension1>(temp);

                    temp.Dimension1Name = pt.Dimension1Name;
                    temp.IsActive       = pt.IsActive;
                    temp.Description    = pt.Description;
                    temp.ModifiedDate   = DateTime.Now;
                    temp.ModifiedBy     = User.Identity.Name;
                    temp.ObjectState    = Model.ObjectState.Modified;
                    _Dimension1Service.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);
                        ViewBag.id   = pt.ProductTypeId;
                        ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductTypeId ?? 0).ProductTypeName;
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.Dimension1).DocumentTypeId,
                        DocId           = temp.Dimension1Id,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    ViewBag.id   = pt.ProductTypeId;
                    ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductTypeId ?? 0).ProductTypeName;
                    return(RedirectToAction("Index", new { id = pt.ProductTypeId }).Success("Data saved successfully"));
                }
            }
            ViewBag.id   = vm.ProductTypeId;
            ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId ?? 0).ProductTypeName;
            return(View("Create", vm));
        }
 public void Delete(Dimension1 pt)
 {
     _unitOfWork.Repository <Dimension1>().Delete(pt);
 }
 public void Update(Dimension1 pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <Dimension1>().Update(pt);
 }
Example #18
0
        public ActionResult Delete(int id)
        {
            Dimension1 header = _Dimension1Service.Find(id);

            return(Remove(id));
        }