// GET: /ProductMaster/Edit/5 public ActionResult EditMaterial(int id) { MaterialViewModel pt = _ProductService.GetMaterialProduct(id); if (pt.ReferenceDocId.HasValue) { var ProductSku = db.Product.Find(pt.ReferenceDocId); pt.ProductSKUId = ProductSku.ProductId; } ProductGroup group = new ProductGroupService(_unitOfWork).Find(pt.ProductGroupId); ProductType Type = new ProductTypeService(_unitOfWork).Find(group.ProductTypeId); ViewBag.Name = Type.ProductTypeName; ViewBag.id = group.ProductTypeId; ViewBag.ProductGroupList = new ProductGroupService(_unitOfWork).GetProductGroupListForItemType(group.ProductTypeId); int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; int SiteId = (int)System.Web.HttpContext.Current.Session["SiteId"]; pt.DivisionId = DivisionId; pt.SiteId = SiteId; if (pt == null) { return(HttpNotFound()); } PrepareMaterialViewBag(pt); return(View("CreateMaterial", pt)); }
public ActionResult ProductGetByID(int ID) { if (!CheckIsLogin()) { return(Redirect(res.Pageviews.PvMemberSignIn)); } var svProduct = new ProductService(); sqlSelect = @"ProductID,ProductCode,ProductName,ProductImgPath,ShortDescription ,ModifiedDate, CreatedDate,RowFlag,ListNo, IsShow,CateLV1,CateLV2,CateLV3,CompID,ProductGroupID,ProductGroupName,CategoryName,ViewCount"; sqlWhere = "ProductID=" + ID; var Product = svProduct.SelectData <view_Product>(sqlSelect, sqlWhere, null, 0, 0).First(); Product.ModifiedDate = DataManager.ConvertToDateTime(Product.ModifiedDate); Product.CreatedDate = DataManager.ConvertToDateTime(Product.CreatedDate); ViewBag.ProductGetByID = Product; var svProductGroup = new ProductGroupService(); var ProductGroups = svProductGroup.GetProductGroup(LogonCompID); if (ProductGroups.Count() > 0) { ViewBag.ProductGroups = ProductGroups; } else { ViewBag.ProductGroups = null; } return(PartialView("UC/QuickProductDetail")); }
public ActionResult PrepareAddProductNotLogin() { var isLogin = CheckIsLogin(); if (!CheckIsLogin()) { CommonService svCommon = new CommonService(); var svProductGroup = new ProductGroupService(); ViewBag.ProductGroups = null; ViewBag.NewTemp = GetRandomCode(5); #region FindCateAll var svCategory = new CategoryService(); var data = svCategory.GetCategoryByLevel(1); ViewBag.SelectCateLV1 = data; #endregion ViewBag.ProductCode = "NPD-" + DateTime.Now.ToString("yyyyMMdd") + "-" + GetRandomCode(5); ViewBag.QtyUnits = svCommon.SelectEnum(CommonService.EnumType.QtyUnits); LoadProvinces(); LoadBiztype(); LoadCategory(); var view = PartialViewToString("UC/AddProductIsNotLogin"); // return PartialView("UC/AddProductIsNotLogin"); return(Json(new { view = view, isLogin = isLogin }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { view = "", isLogin = isLogin }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Recommend() { RememberURL(); if (!CheckIsLogin()) { return(Redirect(res.Pageviews.PvMemberSignIn)); } if (LogonServiceType != 2 && LogonServiceType != 3) { return(Redirect(res.Pageviews.PvAccessDenied)); } var svCategory = new CategoryService(); var svProductGroup = new ProductGroupService(); GetStatusUser(); ViewBag.PageIndex = 1; ViewBag.PageSize = 20; ViewBag.TotalRow = 0; ViewBag.PageType = "Product"; ViewBag.MenuName = "Recommend"; SelectList_PageSize(); DoLoadComboBoxProductStatus(); CountMessage(); CountQuotation(); //select Category ViewBag.IndrustryCateLV1 = svCategory.ListMenuRecommendCategory(LogonCompID); //ViewBag.WholesaleCateLV1 = svCategory.ListWholesaleCategory(LogonCompID); ViewBag.CateLevel1 = LogonCompLevel; return(View()); }
public ActionResult PrepareAddProduct(string GenCode) { if (LogonServiceType != 2 && LogonServiceType != 3) { return(Redirect(res.Pageviews.PvAccessDenied)); } CommonService svCommon = new CommonService(); var svProductGroup = new ProductGroupService(); var ProductGroups = svProductGroup.GetProductGroup(LogonCompID); if (ProductGroups.Count() > 0) { ViewBag.ProductGroups = ProductGroups; } else { ViewBag.ProductGroups = null; } #region FindCateAll var svCategory = new CategoryService(); var data = svCategory.GetCategoryByLevel(1); ViewBag.SelectCateLV1 = data; #endregion ViewBag.QtyUnits = svCommon.SelectEnum(CommonService.EnumType.QtyUnits); ViewBag.ProductCode = GenCode; return(PartialView("UC/AddProduct")); }
public JsonResult GetBaseProductId(int ProductGroupId, int ColourId) { ProductGroup ProductGroup = new ProductGroupService(_unitOfWork).Find(ProductGroupId); Colour Colour = new ColourService(_unitOfWork).Find(ColourId); if (ProductGroup != null && Colour != null) { string ConsumptionProductName = ProductGroup.ProductGroupName.ToString().Trim() + "-" + Colour.ColourName.ToString().Trim() + "-Bom"; var Product = new ProductService(_unitOfWork).Find(ConsumptionProductName); if (Product != null) { return Json(Product.ProductId); } else { return Json(0); } } else { return Json(0); } }
public ActionResult Menu(int?CompID, int?CateID, int?GroupID) { if (CompID > 0) { svProductGroup = new ProductGroupService(); svCategory = new CategoryService(); GetStatusWebsite(); string sqlWhere = "IsDelete = 0 AND ProductCount>0 AND CompID =" + CompID; var ProductGroup = svProductGroup.SelectData <view_ProductGroup>(" * ", sqlWhere, " ListNo ASC, ProductGroupName ASC"); ViewBag.GroupID = GroupID != null ? GroupID : 0; ViewBag.CateID = CateID != null ? CateID : 0; if (svProductGroup.TotalRow > 0) { ViewBag.ProductGroup = ProductGroup; return(PartialView("UC/ProductGroupMenu")); } else { ViewBag.IndrustryCategories = svCategory.ListIndrustryCategory((int)CompID); //ViewBag.WholesaleCategory = svCategory.ListWholesaleCategory((int)CompID); return(PartialView("UC/CategoriesMenu")); } } else { return(Redirect(res.Pageviews.PvNotFound)); } }
public FormProductGroup() { InitializeComponent(); _productGroupService = new ProductGroupService(); _logService = new LogService(); _employeeService = new EmployeeService(); InsertSysLog(); }
public FormAddProductGroup() { InitializeComponent(); _productGroupService = new ProductGroupService(); _employeeService = new EmployeeService(); _logService = new LogService(); txtProductGroupID.Text = _productGroupService.NextId(); }
public FormUpdateProductGroup(string productGroupId) { InitializeComponent(); _productGroupService = new ProductGroupService(); _employeeService = new EmployeeService(); _logService = new LogService(); _productGroupId = productGroupId; GetProductGroupById(productGroupId); }
public FormInsertOrUpdateProductGroup(string productGroupId) { InitializeComponent(); _logService = new LogService(); _productGroupService = new ProductGroupService(); _productGroupId = productGroupId; }
public FormImportProductFormExcel() { InitializeComponent(); _suppliersService = new SuppliersService(); _productGroupService = new ProductGroupService(); _productService = new ProductService(); _stockService = new StockService(); _unitService = new UnitService(); _colorService = new ColorService(); }
public FormInsertOrUpdateProduct(string productId) { InitializeComponent(); _productId = productId; _productService = new ProductService(); _stockService = new StockService(); _productGroupService = new ProductGroupService(); _unitService = new UnitService(); _logService = new LogService(); }
public ActionResult GroupProductList() { if (!CheckIsLogin()) { return(Redirect(res.Pageviews.PvMemberSignIn)); } var svProductGroup = new ProductGroupService(); ViewBag.ProductGroups = svProductGroup.GetProductGroup(LogonCompID); return(PartialView("UC/GroupProductList")); }
public JsonResult GetProductGroupDetailJson(int ProductGroupId) { ProductGroupQuality productgroupquality = new ProductGroupService(_unitOfWork).GetProductGroupQuality(ProductGroupId); List <ProductGroupQuality> ProductGroupQualityJson = new List <ProductGroupQuality>(); ProductGroupQualityJson.Add(new ProductGroupQuality() { ProductGroupName = productgroupquality.ProductGroupName, ProductQualityName = productgroupquality.ProductQualityName }); return(Json(ProductGroupQualityJson)); }
public FormProducts() { InitializeComponent(); _logService = new LogService(); //_departmentService = new DepartmentService(); _productService = new ProductService(); _stockService = new StockService(); _productGroupService = new ProductGroupService(); _unitService = new UnitService(); InsertSysLog(); }
public ActionResult Index(string PStatus, int?GroupID, int?CateLevel, int?CateID) { RememberURL(); string urlSingIn = res.Pageviews.PvMemberSignIn; //if (Prosoft.Base.Base.AppLang == "en-US") { urlSingIn = Regex.Replace(urlSingIn, "~/", "~/en/"); } //else { urlSingIn = res.Pageviews.PvMemberSignIn; } string urlDenied = res.Pageviews.PvAccessDenied; //if (Prosoft.Base.Base.AppLang == "en-US") { urlDenied = Regex.Replace(urlDenied, "~/", "~/en/"); } //else { urlDenied = res.Pageviews.PvAccessDenied; } if (!CheckIsLogin()) { return(Redirect(urlSingIn)); } if (LogonServiceType != 2 && LogonServiceType != 3) { return(Redirect(urlDenied)); } CommonService svCommon = new CommonService(); GetStatusUser(); ViewBag.EnumProductStatus = svCommon.SelectEnum(CommonService.EnumType.ProductStatus); var svCategory = new CategoryService(); var svProductGroup = new ProductGroupService(); ViewBag.PageIndex = 1; ViewBag.TotalRow = 0; ViewBag.PStatus = PStatus != null ? PStatus : "0"; ViewBag.GroupID = GroupID != null ? GroupID : 0; ViewBag.CateLevel = CateLevel != null ? CateLevel : 0; ViewBag.CateID = CateID != null ? CateID : 0; SelectList_PageSize(); DoLoadComboBoxProductStatus(); CountMessage(); CountQuotation(); //select Category ViewBag.IndrustryCateLV1 = svCategory.ListMenuProductCategory(LogonCompID); //ViewBag.WholesaleCateLV1 = svCategory.ListWholesaleCategory(LogonCompID); ViewBag.CateLevel1 = LogonCompLevel; ViewBag.PageType = "Product"; ViewBag.MenuName = "Index"; return(View()); }
public ActionResult SaveGroupProduct(string ProductGroupName, int?GroupID, short?RowVersion) { if (!CheckIsLogin()) { return(Redirect(res.Pageviews.PvMemberSignIn)); } var svProductGroup = new ProductGroupService(); var model = new b2bProductGroup(); try { #region Set Model if (GroupID > 0) { model.ProductGroupID = (int)GroupID; } else { var sqlWhere = "IsDelete = 0 and CompID = " + LogonCompID; var data = svProductGroup.SelectData <b2bProductGroup>("*", sqlWhere, "ListNo DESC"); if (svProductGroup.TotalRow == 0) { model.ListNo = 1; } else { model.ListNo = data.First().ListNo + 1; } } if (RowVersion > 0) { model.RowVersion = (short)RowVersion; } model.ProductGroupName = ProductGroupName; model.CompID = LogonCompID; model.IsShow = true; #endregion svProductGroup.SaveProductGroup(model); } catch (Exception ex) { CreateLogFiles(ex); } return(Json(new { IsResult = svProductGroup.IsResult, MsgError = GenerateMsgError(svProductGroup.MsgError), ID = model.ProductGroupID })); }
public ActionResult DeleteConfirmed(int id) { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); //first find the ProductType Object based on the ID. (sience this object need to marked to be deleted IE. ObjectState.Deleted) var productType = _ProductTypeService.Find(id); LogList.Add(new LogTypeViewModel { ExObj = productType, }); //Then find all the ProductGroups associated with the above ProductType. var productGroups = new ProductGroupService(_unitOfWork).GetProductGroupListForItemType(id); //Mark ObjectState.Delete to all the Product Groups . see ProductGroupService.Delete() foreach (var prodGroup in productGroups) { LogList.Add(new LogTypeViewModel { ExObj = prodGroup, }); new ProductGroupService(_unitOfWork).Delete(prodGroup); } // Now delete the Parent ProductType _ProductTypeService.Delete(productType); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); //Commit the DB _unitOfWork.Save(); LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductType).DocumentTypeId, DocId = productType.ProductTypeId, ActivityType = (int)ActivityTypeContants.Deleted, xEModifications = Modifications, })); return(RedirectToAction("Index").Success("Data deleted successfully")); }
public FormAddProduct() { InitializeComponent(); _productService = new ProductService(); _stockService = new StockService(); _productGroupService = new ProductGroupService(); _unitService = new UnitService(); _suppliersService = new SuppliersService(); _colorService = new ColorService(); _employeeService = new EmployeeService(); _logService = new LogService(); LoadGirdLookUpStock(); LoadGirdLookUpProductGroup(); LoadGirdLookUpSuppliers(); LoadGirdLookUpUnit(); LoadGirdLookUpColor(); txtProductID.Text = _productService.NextId(); txtBarcode.Text = _productService.NextId(); }
public ActionResult ChangeListNoGroup(List <int> id, List <int> no) { if (!CheckIsLogin()) { return(Redirect(res.Pageviews.PvMemberSignIn)); } var svProductGroup = new ProductGroupService(); try { svProductGroup.UpdateProductGroup(id, no); } catch (Exception ex) { CreateLogFiles(ex); } return(Json(new { IsResult = svProductGroup.IsResult, MsgError = GenerateMsgError(svProductGroup.MsgError), ID = id })); }
public FormUpdateProduct(string productId) { InitializeComponent(); _productId = productId; _productService = new ProductService(); _stockService = new StockService(); _productGroupService = new ProductGroupService(); _unitService = new UnitService(); _suppliersService = new SuppliersService(); _colorService = new ColorService(); _employeeService = new EmployeeService(); _logService = new LogService(); GetProductById(productId); LoadGirdLookUpStock(); LoadGirdLookUpProductGroup(); LoadGirdLookUpSuppliers(); LoadGirdLookUpUnit(); LoadGirdLookUpColor(); }
public ActionResult DeleteProductGroup(int GroupID, short RowVersion) { if (!CheckIsLogin()) { return(Redirect(res.Pageviews.PvMemberSignIn)); } var svProductGroup = new ProductGroupService(); try { svProductGroup.Delete(GroupID, LogonCompID); return(Json(new { IsResult = svProductGroup.IsResult, MsgError = GenerateMsgError(svProductGroup.MsgError) })); } catch (Exception ex) { CreateLogFiles(ex); } return(Json(new { IsResult = svProductGroup.IsResult, MsgError = GenerateMsgError(svProductGroup.MsgError) })); }
public ActionResult List(int length, int start, string search) { ProductGroupService svrProductGroup = (new ProductGroupService()); List <tbl_ProductGroup> data = svrProductGroup.getAll(new PagingModel() { offset = start, limit = length, search = search }); int recordsTotal = (int)svrProductGroup.countAll(new PagingModel() { offset = start, limit = length, search = search }); int recordsFiltered = recordsTotal; int draw = 1; try { draw = int.Parse(Request.Params["draw"]); }catch { } return(Json(new { draw, recordsTotal, recordsFiltered, data }, JsonRequestBehavior.AllowGet)); }
public ActionResult PostMaterial(MaterialViewModel pvm) { Product pt1 = new Product(); ProductGroup group = new ProductGroupService(_unitOfWork).Find(pvm.ProductGroupId); ProductType Type = new ProductTypeService(_unitOfWork).Find(group.ProductTypeId); if (pvm.ProductGroupId <= 0) { ModelState.AddModelError("ProductGroupId", "Product Group field is required"); } if (ModelState.IsValid) { //Checking for Create or Edit(<=0 =====>CREATE) if (pvm.ProductId <= 0) { var ProductSKu = db.Product.Find(pvm.ProductSKUId); var PRoductSize = db.ProductSize.Where(m => m.ProductId == ProductSKu.ProductId && m.ProductSizeTypeId == (int)ProductSizeTypeConstants.MapSize).FirstOrDefault(); var Size = db.Size.Find(PRoductSize.SizeId); pt1.ProductName = pvm.ProductName; pt1.ProductCode = pvm.ProductCode; pt1.ProductGroupId = pvm.ProductGroupId; pt1.StandardCost = pvm.StandardCost; pt1.UnitId = pvm.UnitId; pt1.SalesTaxGroupProductId = pvm.SalesTaxGroupProductId; pt1.UnitId = UnitConstants.Pieces; pt1.IsActive = pvm.IsActive; pt1.DivisionId = pvm.DivisionId; pt1.CreatedDate = DateTime.Now; pt1.ModifiedDate = DateTime.Now; pt1.CreatedBy = User.Identity.Name; pt1.ModifiedBy = User.Identity.Name; pt1.ReferenceDocId = pvm.ProductSKUId; pt1.ReferenceDocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.Product).DocumentTypeId; pt1.IsActive = true; pt1.ObjectState = Model.ObjectState.Added; _ProductService.Create(pt1); //Standard Size Data ProductSize standardsize = new ProductSize(); standardsize.ProductSizeTypeId = (int)(ProductSizeTypeConstants.StandardSize); //standardsize.ProductSizeTypeId = 1; standardsize.SizeId = PRoductSize.SizeId; standardsize.ProductId = pt1.ProductId; standardsize.CreatedBy = User.Identity.Name; standardsize.CreatedDate = DateTime.Now; standardsize.ModifiedBy = User.Identity.Name; standardsize.ModifiedDate = DateTime.Now; standardsize.IsActive = true; new ProductSizeService(_unitOfWork).Create(standardsize); UnitConversion UnitConv = new UnitConversion(); UnitConv.CreatedBy = User.Identity.Name; UnitConv.CreatedDate = DateTime.Now; UnitConv.ModifiedBy = User.Identity.Name; UnitConv.ModifiedDate = DateTime.Now; UnitConv.ProductId = pt1.ProductId; UnitConv.FromQty = 1; UnitConv.FromUnitId = UnitConstants.Pieces; UnitConv.ToUnitId = UnitConstants.SqYard; UnitConv.UnitConversionForId = (byte)UnitConversionFors.Standard; using (SqlConnection sqlConnection = new SqlConnection((string)System.Web.HttpContext.Current.Session["DefaultConnectionString"])) { sqlConnection.Open(); SqlCommand Totalf = new SqlCommand("SELECT * FROM Web.FuncConvertSqFeetToSqYard( " + Size.Area + ")", sqlConnection); UnitConv.ToQty = Convert.ToDecimal(Totalf.ExecuteScalar() == DBNull.Value ? 0 : Totalf.ExecuteScalar()); } new UnitConversionService(_unitOfWork).Create(UnitConv); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); PrepareMaterialViewBag(null); ViewBag.Name = Type.ProductTypeName; ViewBag.id = group.ProductTypeId; ViewBag.ProductGroupList = new ProductGroupService(_unitOfWork).GetProductGroupListForItemType(group.ProductTypeId); return(View("CreateMaterial", pvm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.Product).DocumentTypeId, DocId = pt1.ProductId, ActivityType = (int)ActivityTypeContants.Added, })); #region //Saving Images if any uploaded after UnitOfWorkSave if (Request.Files[0] != null && Request.Files[0].ContentLength > 0) { //For checking the first time if the folder exists or not----------------------------- string uploadfolder; int MaxLimit; int.TryParse(ConfigurationManager.AppSettings["MaxFileUploadLimit"], out MaxLimit); var x = (from iid in db.Counter select iid).FirstOrDefault(); if (x == null) { uploadfolder = System.Guid.NewGuid().ToString(); Counter img = new Counter(); img.ImageFolderName = uploadfolder; img.ModifiedBy = User.Identity.Name; img.CreatedBy = User.Identity.Name; img.ModifiedDate = DateTime.Now; img.CreatedDate = DateTime.Now; new CounterService(_unitOfWork).Create(img); _unitOfWork.Save(); } else { uploadfolder = x.ImageFolderName; } //For checking if the image contents length is greater than 100 then create a new folder------------------------------------ if (!Directory.Exists(System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder))) { Directory.CreateDirectory(System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder)); } int count = Directory.GetFiles(System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder)).Length; if (count >= MaxLimit) { uploadfolder = System.Guid.NewGuid().ToString(); var u = new CounterService(_unitOfWork).Find(x.CounterId); u.ImageFolderName = uploadfolder; new CounterService(_unitOfWork).Update(u); _unitOfWork.Save(); } //Saving Thumbnails images: Dictionary <string, string> versions = new Dictionary <string, string>(); //Define the versions to generate versions.Add("_thumb", "maxwidth=100&maxheight=100"); //Crop to square thumbnail versions.Add("_medium", "maxwidth=200&maxheight=200"); //Fit inside 400x400 area, jpeg string temp2 = ""; string filename = System.Guid.NewGuid().ToString(); foreach (string filekey in System.Web.HttpContext.Current.Request.Files.Keys) { HttpPostedFile pfile = System.Web.HttpContext.Current.Request.Files[filekey]; if (pfile.ContentLength <= 0) { continue; //Skip unused file controls. } temp2 = Path.GetExtension(pfile.FileName); string uploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder); if (!Directory.Exists(uploadFolder)) { Directory.CreateDirectory(uploadFolder); } string filecontent = Path.Combine(uploadFolder, pvm.ProductName + "_" + filename); //pfile.SaveAs(filecontent); ImageBuilder.Current.Build(new ImageJob(pfile, filecontent, new Instructions(), false, true)); //Generate each version foreach (string suffix in versions.Keys) { if (suffix == "_thumb") { string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Thumbs"); if (!Directory.Exists(tuploadFolder)) { Directory.CreateDirectory(tuploadFolder); } //Generate a filename (GUIDs are best). string tfileName = Path.Combine(tuploadFolder, pvm.ProductName + "_" + filename); //Let the image builder add the correct extension based on the output file type //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true); ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true)); } else if (suffix == "_medium") { string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Medium"); if (!Directory.Exists(tuploadFolder)) { Directory.CreateDirectory(tuploadFolder); } //Generate a filename (GUIDs are best). string tfileName = Path.Combine(tuploadFolder, pvm.ProductName + "_" + filename); //Let the image builder add the correct extension based on the output file type //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true); ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true)); } } //var tempsave = _FinishedProductService.Find(pt.ProductId); var tempsave = _ProductService.Find(pt1.ProductId); tempsave.ImageFileName = pvm.ProductName + "_" + filename + temp2; tempsave.ImageFolderName = uploadfolder; _ProductService.Update(tempsave); _unitOfWork.Save(); } } #endregion return(RedirectToAction("CreateMaterial", new { id = group.ProductTypeId }).Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); Product pt = _ProductService.Find(pvm.ProductId); Product ExRec = Mapper.Map <Product>(pt); pt.ProductName = pvm.ProductName; pt.ProductCode = pvm.ProductCode; pt.StandardCost = pvm.StandardCost; pt.ProductGroupId = pvm.ProductGroupId; pt.SalesTaxGroupProductId = pvm.SalesTaxGroupProductId; pt.IsActive = pvm.IsActive; pt.ModifiedDate = DateTime.Now; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Modified; _ProductService.Update(pt); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = pt, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); PrepareMaterialViewBag(pvm); ViewBag.Name = Type.ProductTypeName; ViewBag.id = group.ProductTypeId; ViewBag.ProductGroupList = new ProductGroupService(_unitOfWork).GetProductGroupListForItemType(group.ProductTypeId); return(View("CreateMaterial", pvm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.Product).DocumentTypeId, DocId = pt.ProductId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); #region //Saving Image if file is uploaded if (Request.Files[0] != null && Request.Files[0].ContentLength > 0) { string uploadfolder = pt.ImageFolderName; string tempfilename = pt.ImageFileName; if (uploadfolder == null) { var x = (from iid in db.Counter select iid).FirstOrDefault(); if (x == null) { uploadfolder = System.Guid.NewGuid().ToString(); Counter img = new Counter(); img.ImageFolderName = uploadfolder; img.ModifiedBy = User.Identity.Name; img.CreatedBy = User.Identity.Name; img.ModifiedDate = DateTime.Now; img.CreatedDate = DateTime.Now; new CounterService(_unitOfWork).Create(img); _unitOfWork.Save(); } else { uploadfolder = x.ImageFolderName; } } //Deleting Existing Images var xtemp = System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/" + tempfilename); if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/" + tempfilename))) { System.IO.File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/" + tempfilename)); } //Deleting Thumbnail Image: if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Thumbs/" + tempfilename))) { System.IO.File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Thumbs/" + tempfilename)); } //Deleting Medium Image: if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Medium/" + tempfilename))) { System.IO.File.Delete(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/" + uploadfolder + "/Medium/" + tempfilename)); } //Saving Thumbnails images: Dictionary <string, string> versions = new Dictionary <string, string>(); //Define the versions to generate versions.Add("_thumb", "maxwidth=100&maxheight=100"); //Crop to square thumbnail versions.Add("_medium", "maxwidth=200&maxheight=200"); //Fit inside 400x400 area, jpeg var temo = pt.ProductName.Replace(" ", string.Empty); string temp2 = ""; string filename = System.Guid.NewGuid().ToString(); foreach (string filekey in System.Web.HttpContext.Current.Request.Files.Keys) { HttpPostedFile pfile = System.Web.HttpContext.Current.Request.Files[filekey]; if (pfile.ContentLength <= 0) { continue; //Skip unused file controls. } temp2 = Path.GetExtension(pfile.FileName); string uploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder); if (!Directory.Exists(uploadFolder)) { Directory.CreateDirectory(uploadFolder); } string filecontent = Path.Combine(uploadFolder, pt.ProductName + "_" + filename); //pfile.SaveAs(filecontent); ImageBuilder.Current.Build(new ImageJob(pfile, filecontent, new Instructions(), false, true)); //Generate each version foreach (string suffix in versions.Keys) { if (suffix == "_thumb") { string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Thumbs"); if (!Directory.Exists(tuploadFolder)) { Directory.CreateDirectory(tuploadFolder); } //Generate a filename (GUIDs are best). string tfileName = Path.Combine(tuploadFolder, pt.ProductName + "_" + filename); //Let the image builder add the correct extension based on the output file type //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true); ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true)); } else if (suffix == "_medium") { string tuploadFolder = System.Web.HttpContext.Current.Request.MapPath("~/Uploads/" + uploadfolder + "/Medium"); if (!Directory.Exists(tuploadFolder)) { Directory.CreateDirectory(tuploadFolder); } //Generate a filename (GUIDs are best). string tfileName = Path.Combine(tuploadFolder, pt.ProductName + "_" + filename); //Let the image builder add the correct extension based on the output file type //fileName = ImageBuilder.Current.Build(file, fileName, new ResizeSettings(versions[suffix]), false, true); ImageBuilder.Current.Build(new ImageJob(pfile, tfileName, new Instructions(versions[suffix]), false, true)); } } } var temsave = _ProductService.Find(pt.ProductId); temsave.ImageFileName = pt.ProductName + "_" + filename + temp2; temsave.ImageFolderName = uploadfolder; _ProductService.Update(temsave); _unitOfWork.Save(); } #endregion return(RedirectToAction("MaterialIndex", new { id = group.ProductTypeId }).Success("Data saved successfully")); } } PrepareMaterialViewBag(pvm); return(View("CreateMaterial", pvm)); }
public ActionResult Post(ProductGroupProcessSettingsViewModel vm) { ProductGroupProcessSettings pt = AutoMapper.Mapper.Map <ProductGroupProcessSettingsViewModel, ProductGroupProcessSettings>(vm); if (ModelState.IsValid) { ProductGroup ProductGroup = new ProductGroupService(_unitOfWork).Find(vm.ProductGroupId); if (vm.ProductGroupProcessSettingsId <= 0) { pt.CreatedDate = DateTime.Now; pt.ModifiedDate = DateTime.Now; pt.CreatedBy = User.Identity.Name; pt.ModifiedBy = User.Identity.Name; pt.ObjectState = Model.ObjectState.Added; _ProductGroupProcessSettingsService.Create(pt); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); PrepareViewBag(vm); return(View("Create", vm)); } int DocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.Carpet).DocumentTypeId; LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocId = pt.ProductGroupProcessSettingsId, DocTypeId = DocTypeId, ActivityType = (int)ActivityTypeContants.SettingsAdded, })); return(RedirectToAction("Index", "ProductGroupProcessSettings", new { id = ProductGroup.ProductGroupId }).Success("Data saved successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); ProductGroupProcessSettings temp = _ProductGroupProcessSettingsService.Find(pt.ProductGroupProcessSettingsId); ProductGroupProcessSettings ExRec = Mapper.Map <ProductGroupProcessSettings>(temp); temp.ProcessId = vm.ProcessId; temp.QAGroupId = vm.QAGroupId; temp.ModifiedDate = DateTime.Now; temp.ModifiedBy = User.Identity.Name; temp.ObjectState = Model.ObjectState.Modified; _ProductGroupProcessSettingsService.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); return(View("Create", pt)); } int DocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.Carpet).DocumentTypeId; LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocId = temp.ProductGroupProcessSettingsId, ActivityType = (int)ActivityTypeContants.SettingsModified, DocTypeId = DocTypeId, xEModifications = Modifications, })); return(RedirectToAction("Index", "ProductGroupProcessSettings", new { id = ProductGroup.ProductGroupId }).Success("Data saved successfully")); } } PrepareViewBag(vm); return(View("Create", vm)); }
public ActionResult CopyFromExisting(CopyFromExistingDesignConsumptionViewModel vm) { if (ModelState.IsValid) { Product OldProduct = _ProductService.Find(vm.ProductId); FinishedProduct NewProduct = new FinishedProduct(); ProductGroup productgroup = new ProductGroupService(_unitOfWork).Find(vm.ProductGroupId); if (productgroup.ProductGroupName.Length > 20) { NewProduct.ProductCode = productgroup.ProductGroupName.ToString().Substring(0, 20); } else { NewProduct.ProductCode = productgroup.ProductGroupName.ToString().Substring(0, productgroup.ProductGroupName.Length); } NewProduct.ProductName = productgroup.ProductGroupName; NewProduct.ProductGroupId = new ProductGroupService(_unitOfWork).Find(ProductGroupConstants.Bom).ProductGroupId; NewProduct.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; NewProduct.IsActive = true; NewProduct.CreatedDate = DateTime.Now; NewProduct.ModifiedDate = DateTime.Now; NewProduct.CreatedBy = User.Identity.Name; NewProduct.ModifiedBy = User.Identity.Name; NewProduct.ReferenceDocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductGroup).DocumentTypeId; NewProduct.ReferenceDocId = productgroup.ProductGroupId; NewProduct.IsSample = false; NewProduct.ObjectState = Model.ObjectState.Added; _ProductService.Create(NewProduct); var ProductList = (from p in db.Product where p.ProductGroupId == productgroup.ProductGroupId select new { ProductId = p.ProductId }).ToList(); foreach (var item in ProductList) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = item.ProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = 100; bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId; bomdetail.ProductId = NewProduct.ProductId; bomdetail.Qty = 1; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); } IEnumerable <BomDetail> BomDetailList = new BomDetailService(_unitOfWork).GetBomDetailList(OldProduct.ProductId); foreach (BomDetail item in BomDetailList) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = NewProduct.ProductId; bomdetail.BatchQty = item.BatchQty; bomdetail.ConsumptionPer = item.ConsumptionPer; bomdetail.Dimension1Id = item.Dimension1Id; bomdetail.ProcessId = item.ProcessId; bomdetail.ProductId = item.ProductId; bomdetail.Qty = item.Qty; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("CopyFromExisting", vm)); } return(Json(new { success = true, Url = "/DesignConsumptionHeader/Edit/" + NewProduct.ProductId })); } return(PartialView("CopyFromExisting", vm)); }
public ActionResult Create(DesignConsumptionHeaderViewModel svm) { if (ModelState.IsValid) { if (svm.BaseProductId == 0) { FinishedProduct product = new FinishedProduct(); if (svm.ProductGroupName.Length > 20) { product.ProductCode = svm.ProductGroupName.ToString().Substring(0, 20); } else { product.ProductCode = svm.ProductGroupName.ToString().Substring(0, svm.ProductGroupName.Length); } product.ProductName = svm.ProductGroupName; product.ProductGroupId = new ProductGroupService(_unitOfWork).Find(ProductGroupConstants.Bom).ProductGroupId; product.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; product.IsActive = true; product.ReferenceDocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductGroup).DocumentTypeId; product.ReferenceDocId = svm.ProductGroupId; product.IsSample = false; product.CreatedDate = DateTime.Now; product.ModifiedDate = DateTime.Now; product.CreatedBy = User.Identity.Name; product.ModifiedBy = User.Identity.Name; product.ObjectState = Model.ObjectState.Added; _ProductService.Create(product); ProductGroup ProductGroup = new ProductGroupService(_unitOfWork).Find(svm.ProductGroupName); if (ProductGroup != null) { var ProductList = (from p in db.Product where p.ProductGroupId == ProductGroup.ProductGroupId select new { ProductId = p.ProductId }).ToList(); foreach (var item in ProductList) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = item.ProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = 100; bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId; bomdetail.ProductId = product.ProductId; bomdetail.Qty = 1; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); } } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(View(svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.DesignConsumption).DocumentTypeId, DocId = product.ProductId, ActivityType = (int)ActivityTypeContants.Added, })); //return RedirectToAction("Create").Success("Data saved successfully"); return(RedirectToAction("Edit", new { id = product.ProductId }).Success("Data saved Successfully")); } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); Product product = _ProductService.Find(svm.BaseProductId); Product ExRec = Mapper.Map <Product>(product); if (svm.ProductGroupName.Length > 20) { product.ProductCode = svm.ProductGroupName.ToString().Substring(0, 20); } else { product.ProductCode = svm.ProductGroupName.ToString().Substring(0, svm.ProductGroupName.Length); } product.ProductName = svm.ProductGroupName; product.ReferenceDocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductGroup).DocumentTypeId; product.ReferenceDocId = svm.ProductGroupId; product.ModifiedBy = User.Identity.Name; product.ModifiedDate = DateTime.Now; StringBuilder logstring = new StringBuilder(); _ProductService.Update(product); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = product, }); 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).Find(MasterDocTypeConstants.DesignConsumption).DocumentTypeId, DocId = product.ProductId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(RedirectToAction("Index").Success("Data saved successfully")); } } PrepareViewBag(); return(View(svm)); }
public FormImportProductGroupFormExcel() { InitializeComponent(); _productGroupService = new ProductGroupService(); }
public ActionResult _CreatePost(DesignConsumptionLineViewModel svm) { if (ModelState.IsValid) { FinishedProduct product = new FinishedProduct(); if (svm.BaseProductId == 0) { ProductQuality Quality = new ProductQualityService(_unitOfWork).Find(svm.QualityName); string ConsumptionProductName = ""; if (svm.ColourName != "" && svm.ColourName != null) { ConsumptionProductName = svm.DesignName.ToString().Trim() + "-" + svm.ColourName.ToString().Trim() + "-Bom"; } else { ConsumptionProductName = svm.DesignName.ToString().Trim() + "-Bom"; } int ProductGroupId = new ProductGroupService(_unitOfWork).Find(svm.DesignName).ProductGroupId; product.ProductCode = ConsumptionProductName; product.ProductName = ConsumptionProductName; product.ProductGroupId = new ProductGroupService(_unitOfWork).Find(ProductGroupConstants.Bom).ProductGroupId; product.DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"]; product.IsActive = true; product.ReferenceDocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.ProductGroup).DocumentTypeId; product.ReferenceDocId = ProductGroupId; product.StandardWeight = svm.Weight; product.CreatedDate = DateTime.Now; product.ModifiedDate = DateTime.Now; product.CreatedBy = User.Identity.Name; product.ModifiedBy = User.Identity.Name; product.ObjectState = Model.ObjectState.Added; product.IsSample = false; product.ProductQualityId = Quality.ProductQualityId; new ProductService(_unitOfWork).Create(product); ProductGroup ProductGroup = new ProductGroupService(_unitOfWork).Find(svm.DesignName); Colour Colour = new ColourService(_unitOfWork).Find(svm.ColourName); if (ProductGroup != null && Colour != null) { var ProductList = (from p in db.FinishedProduct where p.ProductGroupId == ProductGroup.ProductGroupId && p.ColourId == Colour.ColourId select new { ProductId = p.ProductId }).ToList(); foreach (var item in ProductList) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = item.ProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = 100; bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId; bomdetail.BaseProcessId = svm.BaseProcessId; bomdetail.ProductId = product.ProductId; bomdetail.Qty = 1; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); } } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.DesignColourConsumption).DocumentTypeId, DocId = product.ProductId, ActivityType = (int)ActivityTypeContants.Added, })); } else { //product = new FinishedProductService(_unitOfWork).Find(svm.BaseProductId); product.ProductId = svm.BaseProductId; } if (svm.BomDetailId == 0) { BomDetail bomdetail = new BomDetail(); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = svm.ConsumptionPer; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.ProcessId = new ProcessService(_unitOfWork).Find(ProcessConstants.Weaving).ProcessId; bomdetail.BaseProcessId = svm.BaseProcessId; bomdetail.ProductId = svm.ProductId; bomdetail.Qty = svm.Qty; bomdetail.CreatedDate = DateTime.Now; bomdetail.ModifiedDate = DateTime.Now; bomdetail.CreatedBy = User.Identity.Name; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Added; _BomDetailService.Create(bomdetail); if (bomdetail.BaseProductId == bomdetail.ProductId) { PrepareViewBag(svm); //return View(svm).Danger(DataValidationMsg); ModelState.AddModelError("", "Invalid Product is Selected!"); return(PartialView("_Create", svm)); } try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.DesignConsumption).DocumentTypeId, DocId = bomdetail.BomDetailId, ActivityType = (int)ActivityTypeContants.Added, })); if (svm.ContentType == "Main Contents") { return(RedirectToAction("_CreateMainContentForBaseProduct", new { id = product.ProductId })); } else if (svm.ContentType == "OverTuft Contents") { return(RedirectToAction("_CreateOverTuftContentForBaseProduct", new { id = product.ProductId })); } else { return(RedirectToAction("_CreateOtherContentForBaseProduct", new { id = product.ProductId })); } } else { List <LogTypeViewModel> LogList = new List <LogTypeViewModel>(); BomDetail bomdetail = _BomDetailService.Find(svm.BomDetailId); BomDetail ExRec = Mapper.Map <BomDetail>(bomdetail); bomdetail.BaseProductId = svm.BaseProductId; bomdetail.BatchQty = 1; bomdetail.ConsumptionPer = svm.ConsumptionPer; bomdetail.Dimension1Id = svm.Dimension1Id; bomdetail.ProductId = svm.ProductId; bomdetail.Qty = svm.Qty; bomdetail.ModifiedDate = DateTime.Now; bomdetail.ModifiedBy = User.Identity.Name; bomdetail.ObjectState = Model.ObjectState.Modified; _BomDetailService.Update(bomdetail); LogList.Add(new LogTypeViewModel { ExObj = ExRec, Obj = bomdetail, }); XElement Modifications = new ModificationsCheckService().CheckChanges(LogList); try { _unitOfWork.Save(); } catch (Exception ex) { string message = _exception.HandleException(ex); ModelState.AddModelError("", message); return(PartialView("_Create", svm)); } LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel { DocTypeId = new DocumentTypeService(_unitOfWork).FindByName(MasterDocTypeConstants.DesignConsumption).DocumentTypeId, DocId = bomdetail.BomDetailId, ActivityType = (int)ActivityTypeContants.Modified, xEModifications = Modifications, })); return(Json(new { success = true })); } } PrepareViewBag(svm); return(PartialView("_Create", svm)); }