Example #1
0
        // GET: /ProductCustomGroupHeader/Edit/5
        public ActionResult Edit(int id)
        {
            ProductCustomGroupHeader s = _ProductCustomGroupHeaderService.GetProductCustomGroupHeader(id);

            if (s == null)
            {
                return(HttpNotFound());
            }
            return(View("Create", s));
        }
Example #2
0
        // GET: /PurchaseOrderHeader/Delete/5

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

            if (ProductCustomGroupHeader == null)
            {
                return(HttpNotFound());
            }
            ReasonViewModel rvm = new ReasonViewModel()
            {
                id = id,
            };

            return(PartialView("_Reason", rvm));
        }
Example #3
0
 public void Update(ProductCustomGroupHeader s)
 {
     s.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <ProductCustomGroupHeader>().Update(s);
 }
Example #4
0
 public void Delete(ProductCustomGroupHeader s)
 {
     _unitOfWork.Repository <ProductCustomGroupHeader>().Delete(s);
 }
Example #5
0
 public ProductCustomGroupHeader Create(ProductCustomGroupHeader s)
 {
     s.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <ProductCustomGroupHeader>().Insert(s);
     return(s);
 }
        public ActionResult ProductCustomGroupExcelImport()
        {
            var    file     = Request.Files[0];
            string filePath = Request.MapPath(ConfigurationManager.AppSettings["ExcelFilePath"] + file.FileName);

            file.SaveAs(filePath);
            var excel = new ExcelQueryFactory();

            //excel.FileName =ConfigurationManager.AppSettings["ExcelFilePath"]; //  @"C:\Users\guru\Downloads\PO.xls"; //TODO: Rempve hardcode
            excel.FileName = filePath;
            var ProductCustomGroupRecordList = from c in excel.Worksheet <ProductCustomGroupExcelViewModel>() select c;

            StringBuilder strProduct = new StringBuilder();

            foreach (var ProductCustomGroupRecord in ProductCustomGroupRecordList)
            {
                if (_ProductService.Find(ProductCustomGroupRecord.ProductName) == null)
                {
                    if (!strProduct.ToString().Contains("" + ProductCustomGroupRecord.ProductName))
                    {
                        strProduct.Append(" " + ProductCustomGroupRecord.ProductName + ",");
                    }
                }
            }
            if (!string.IsNullOrEmpty(strProduct.ToString()))
            {
                if (string.IsNullOrEmpty(strProduct.ToString()))
                {
                    ViewBag.product = null;
                }
                else
                {
                    ViewBag.product = strProduct;
                }
                return(View());
            }
            else
            {
                string previousRecord          = null;
                int    count                   = 0;
                ProductCustomGroupHeader stemp = new ProductCustomGroupHeader();
                foreach (var ProductCustomGroupRecord in ProductCustomGroupRecordList)
                {
                    if (count == 0 || ProductCustomGroupRecord.ProductCustomGroupName != previousRecord)
                    {
                        ProductCustomGroupHeader s = new ProductCustomGroupHeader();
                        s.ProductCustomGroupName = ProductCustomGroupRecord.ProductCustomGroupName;
                        s.IsActive     = true;
                        s.CreatedDate  = DateTime.Now;
                        s.ModifiedDate = DateTime.Now;
                        s.CreatedBy    = User.Identity.Name;
                        s.ModifiedBy   = User.Identity.Name;

                        _ProductCustomGroupHeaderService.Create(s);
                        stemp = s;
                    }

                    //Object for ProductCustomGroupLineDetail Model to Save Rate, Quantity, Product

                    Product product           = _ProductService.Find(ProductCustomGroupRecord.ProductName);
                    ProductCustomGroupLine sl = new ProductCustomGroupLine();
                    sl.ProductCustomGroupHeaderId = stemp.ProductCustomGroupId;
                    sl.ProductId    = product.ProductId;
                    sl.Qty          = ProductCustomGroupRecord.Qty;
                    sl.CreatedDate  = DateTime.Now;
                    sl.ModifiedDate = DateTime.Now;
                    sl.CreatedBy    = User.Identity.Name;
                    sl.ModifiedBy   = User.Identity.Name;



                    _ProductCustomGroupLineService.Create(sl);

                    count++;
                    previousRecord = ProductCustomGroupRecord.ProductCustomGroupName;

                    _unitOfWork.Save();
                }

                return(View("Sucess"));
            }
        }
Example #7
0
        // GET: /ProductCustomGroupHeader/Create

        public ActionResult Create()
        {
            ProductCustomGroupHeader vm = new ProductCustomGroupHeader();

            return(View("Create", vm));
        }
Example #8
0
        public ActionResult HeaderPost(ProductCustomGroupHeader svm)
        {
            if (ModelState.IsValid)
            {
                if (svm.ProductCustomGroupId == 0)
                {
                    svm.CreatedDate  = DateTime.Now;
                    svm.ModifiedDate = DateTime.Now;
                    svm.CreatedBy    = User.Identity.Name;
                    svm.ModifiedBy   = User.Identity.Name;
                    _ProductCustomGroupHeaderService.Create(svm);

                    try
                    {
                        _unitOfWork.Save();
                    }

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

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

                    //return RedirectToAction("Create", "SaleOrderLine", new { Id = s.ProductCustomGroupHeaderId }).Success("Data saved successfully");
                    return(RedirectToAction("Edit", new { id = svm.ProductCustomGroupId }).Success("Data saved Successfully"));
                }
                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

                    ProductCustomGroupHeader temp = _ProductCustomGroupHeaderService.Find(svm.ProductCustomGroupId);

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

                    temp.ProductCustomGroupName = svm.ProductCustomGroupName;
                    temp.IsActive     = svm.IsActive;
                    temp.ModifiedDate = DateTime.Now;
                    temp.ModifiedBy   = User.Identity.Name;
                    _ProductCustomGroupHeaderService.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);
                        return(View("Create", svm));
                    }

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

                    return(RedirectToAction("Index").Success("Data saved successfully"));
                }
            }
            return(View("Create", svm));
        }