/// <summary> /// </summary> /// <param name="entity"/> /// <returns/> public bool OnAfterLoad_ProductMaster(ProductMaster entity) { MicronBETestProcess process = FindHelper.FindProcess(entity.PROCESS_ID); if (process == null) { return(false); } MicronBETestProduct product = new MicronBETestProduct(entity.PRODUCT_ID, process); product.LineID = entity.LINE_ID; //product.IsFinal = entity.IS_FINAL == "Y" ? true : false; //product.Grade = string.IsNullOrEmpty(entity.GRADE) ? "Z" : entity.GRADE; if (InputMart.Instance.MicronBETestProduct.ContainsKey(entity.PRODUCT_ID) == false) { InputMart.Instance.MicronBETestProduct.Add(entity.PRODUCT_ID, product); } return(false); }
public ActionResult Create(FormCollection collection) { ReturnResult returnResult = new ReturnResult(); ProductMaster objProduct = new ProductMaster(); try { // TODO: Add insert logic here ProductBL productBL = new ProductBL(); objProduct.ProductId = 0; objProduct.ProductName = Convert.ToString(collection["ProductName"]); objProduct.ProductCode = Convert.ToString(collection["ProductCode"]); objProduct.BarCode = Convert.ToString(collection["BarCode"]); objProduct.CategoryId = Convert.ToInt32(collection["CategoryId"]); objProduct.SupplierId = Convert.ToInt32(collection["SupplierId"]); //objProduct.UOM = Convert.ToInt32(collection["UOM"]); objProduct.CompanyPrice = Convert.ToDecimal(collection["CompanyPrice"]); objProduct.RePOorderLevel = Convert.ToInt32(collection["RePOorderLevel"]); objProduct.RePOorderQuantity = Convert.ToInt32(collection["RePOorderQuantity"]); returnResult = productBL.SaveProduct(objProduct); if (returnResult.IsSuccess) { return(RedirectToAction("Index")); } else { TempData["CreateProductMessage"] = returnResult.Message; return(View(objProduct)); } } catch { TempData["CreateProductMessage"] = returnResult.Message; return(View(objProduct)); } }
private void Create(int ii) { var producer = new Producer { Name = "Producer" }; _repo.Save(producer); var parent = new ProductMaster { Name = "Produkt " + ii, Description = LoremIpsum.Text }; _repo.Save(parent); foreach (var color in new EnumMeta <Color>().GetValues()) { var variant = new ProductVariant(parent) { Color = color }; parent.Add(variant); } _repo.Commit(); }
public ActionResult ProductMaster(ProductMaster Product) { string submittype = Request.Form["hid_submit"]; string hid_productId = Request.Form["hid_ProductId"]; string hid_typeId = Request.Form["hid_ProductTypeId"]; if (submittype == "1") { return(RedirectToAction("ProductMaster", "ProductMaster", new { area = "Product" })); } else if (submittype == "2") { return(RedirectToAction("Index", "AuthorContract", new { area = "Contract", ProductId = hid_productId })); } else if (submittype == "3") { return(RedirectToAction("ProductLicense", "ProductLicense", new { area = "Product", Id = hid_productId })); } else { return(null); } }
public ProductMasterUpdateDataParameters(ProductMaster val) { ProductMaster = val; Build(); }
public DataBaseResultSet SaveProductMaster <T>(T objData) where T : class, IModel, new() { ProductMaster obj = objData as ProductMaster; string sQuery = "sprocProductMasterInsertUpdateSingleItem"; List <DbParameter> list = new List <DbParameter>(); list.Add(SqlConnManager.GetConnParameters("ProductCode", "ProductCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.ProductCode)); list.Add(SqlConnManager.GetConnParameters("ICode", "ICode", 50, GenericDataType.String, ParameterDirection.Input, obj.ICode)); list.Add(SqlConnManager.GetConnParameters("ProductName", "ProductName", 50, GenericDataType.String, ParameterDirection.Input, obj.ProductName)); list.Add(SqlConnManager.GetConnParameters("Packing", "Packing", 50, GenericDataType.String, ParameterDirection.Input, obj.Packing)); list.Add(SqlConnManager.GetConnParameters("PackingType", "PackingType", 50, GenericDataType.String, ParameterDirection.Input, obj.PackingType)); list.Add(SqlConnManager.GetConnParameters("ConversionUnit", "ConversionUnit", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.ConversionUnit)); list.Add(SqlConnManager.GetConnParameters("CompanyTag", "CompanyTag", 50, GenericDataType.String, ParameterDirection.Input, obj.CompanyTag)); list.Add(SqlConnManager.GetConnParameters("CompanyCode", "CompanyCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.CompanyCode)); list.Add(SqlConnManager.GetConnParameters("CategoryCode", "CategoryCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.CategoryCode)); list.Add(SqlConnManager.GetConnParameters("GenericCode", "GenericCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.GenericCode)); list.Add(SqlConnManager.GetConnParameters("Rate", "Rate", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.Rate)); list.Add(SqlConnManager.GetConnParameters("SplRate", "SplRate", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.SplRate)); list.Add(SqlConnManager.GetConnParameters("DiscYN", "DiscYN", 50, GenericDataType.String, ParameterDirection.Input, obj.DiscYN)); list.Add(SqlConnManager.GetConnParameters("Discount", "Discount", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.Discount)); list.Add(SqlConnManager.GetConnParameters("Inclusive", "Inclusive", 50, GenericDataType.String, ParameterDirection.Input, obj.Inclusive)); list.Add(SqlConnManager.GetConnParameters("VatOn", "VatOn", 50, GenericDataType.String, ParameterDirection.Input, obj.VatOn)); list.Add(SqlConnManager.GetConnParameters("Vat", "Vat", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.Vat)); list.Add(SqlConnManager.GetConnParameters("AdVat", "AdVat", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.AdVat)); list.Add(SqlConnManager.GetConnParameters("CST", "CST", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.CST)); list.Add(SqlConnManager.GetConnParameters("BarPrint", "BarPrint", 50, GenericDataType.String, ParameterDirection.Input, obj.BarPrint)); list.Add(SqlConnManager.GetConnParameters("BarCode", "BarCode", 13, GenericDataType.String, ParameterDirection.Input, obj.BarCode)); list.Add(SqlConnManager.GetConnParameters("MinQty", "MinQty", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.MinQty)); list.Add(SqlConnManager.GetConnParameters("MaxQty", "MaxQty", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.MaxQty)); list.Add(SqlConnManager.GetConnParameters("ReOrderQty", "ReOrderQty", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.ReOrderQty)); list.Add(SqlConnManager.GetConnParameters("RackID", "RackID", 50, GenericDataType.String, ParameterDirection.Input, obj.RackID)); list.Add(SqlConnManager.GetConnParameters("TStk", "TStk", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.TStk)); list.Add(SqlConnManager.GetConnParameters("LPurRs", "LPurRs", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.LPurRs)); list.Add(SqlConnManager.GetConnParameters("ImageName", "ImageName", 50, GenericDataType.String, ParameterDirection.Input, obj.ImageName)); list.Add(SqlConnManager.GetConnParameters("Scheme", "Scheme", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.Scheme)); list.Add(SqlConnManager.GetConnParameters("SQty", "SQty", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.SQty)); list.Add(SqlConnManager.GetConnParameters("SFQty", "SFQty", 8, GenericDataType.Decimal, ParameterDirection.Input, obj.SFQty)); list.Add(SqlConnManager.GetConnParameters("NDRX", "NDRX", 3, GenericDataType.String, ParameterDirection.Input, obj.NDRX)); list.Add(SqlConnManager.GetConnParameters("CUser", "CUser", 8, GenericDataType.Long, ParameterDirection.Input, obj.CUser)); list.Add(SqlConnManager.GetConnParameters("CDateTime", "CDateTime", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.CDateTime)); list.Add(SqlConnManager.GetConnParameters("EUser", "EUser", 8, GenericDataType.Long, ParameterDirection.Input, obj.EUser)); list.Add(SqlConnManager.GetConnParameters("EDateTime", "EDateTime", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.EDateTime)); list.Add(SqlConnManager.GetConnParameters("LCode", "LCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.LCode)); list.Add(SqlConnManager.GetConnParameters("SaleCatCode", "SaleCatCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.SaleCatCode)); list.Add(SqlConnManager.GetConnParameters("OldProductCode", "OldProductCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.OldProductCode)); list.Add(SqlConnManager.GetConnParameters("DoctorCode", "DoctorCode", 8, GenericDataType.Long, ParameterDirection.Input, obj.DoctorCode)); list.Add(SqlConnManager.GetConnParameters("DLock", "DLock", 3, GenericDataType.String, ParameterDirection.Input, obj.DLock)); list.Add(SqlConnManager.GetConnParameters("SchDrg", "SchDrg", 10, GenericDataType.String, ParameterDirection.Input, obj.SchDrg)); list.Add(SqlConnManager.GetConnParameters("Note1", "Note1", 200, GenericDataType.String, ParameterDirection.Input, obj.Note1)); list.Add(SqlConnManager.GetConnParameters("Fav", "Fav", 3, GenericDataType.String, ParameterDirection.Input, obj.Fav)); list.Add(SqlConnManager.GetConnParameters("CreatedBy", "CreatedBy", 50, GenericDataType.String, ParameterDirection.Input, obj.CreatedBy)); list.Add(SqlConnManager.GetConnParameters("CreatedDate", "CreatedDate", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.CreatedDate)); list.Add(SqlConnManager.GetConnParameters("UpdateddBy", "UpdateddBy", 50, GenericDataType.String, ParameterDirection.Input, obj.UpdateddBy)); list.Add(SqlConnManager.GetConnParameters("UpdatedDate", "UpdatedDate", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.UpdatedDate)); list.Add(SqlConnManager.GetConnParameters("UpdatedCount", "UpdatedCount", 4, GenericDataType.Int, ParameterDirection.Input, obj.UpdatedCount)); list.Add(SqlConnManager.GetConnParameters("LUT", "LUT", 8, GenericDataType.DateTime, ParameterDirection.Input, obj.LUT)); list.Add(SqlConnManager.GetConnParameters("OperationFlag", "OperationFlag", 4, GenericDataType.Int, ParameterDirection.Input, (short)obj.OperationFlag)); list.Add(SqlConnManager.GetConnParameters("Message", "Message", 300, GenericDataType.String, ParameterDirection.Output, null)); list.Add(SqlConnManager.GetConnParameters("ErrorCode", "ErrorCode", 4, GenericDataType.Int, ParameterDirection.Output, null)); return(SqlConnManager.Save(sQuery, CommandType.StoredProcedure, list.ToArray())); }
public static bool Delete(ProductMaster ProductMaster) { SqlConnection connection = plansoni_webstoreData.GetConnection(); string deleteProcedure = "[ProductMasterDelete]"; SqlCommand deleteCommand = new SqlCommand(deleteProcedure, connection); deleteCommand.CommandType = CommandType.StoredProcedure; deleteCommand.Parameters.AddWithValue("@OldProductId", ProductMaster.ProductId); if (ProductMaster.Model != null) { deleteCommand.Parameters.AddWithValue("@OldModel", ProductMaster.Model); } else { deleteCommand.Parameters.AddWithValue("@OldModel", DBNull.Value); } if (ProductMaster.Partno != null) { deleteCommand.Parameters.AddWithValue("@OldPartno", ProductMaster.Partno); } else { deleteCommand.Parameters.AddWithValue("@OldPartno", DBNull.Value); } if (ProductMaster.manufacturerId.HasValue == true) { deleteCommand.Parameters.AddWithValue("@OldmanufacturerId", ProductMaster.manufacturerId); } else { deleteCommand.Parameters.AddWithValue("@OldmanufacturerId", DBNull.Value); } if (ProductMaster.ProductTypeId.HasValue == true) { if (ProductMaster.ProductTypeId == 0) { deleteCommand.Parameters.AddWithValue("@OldProductTypeId", DBNull.Value); } else { deleteCommand.Parameters.AddWithValue("@OldProductTypeId", ProductMaster.ProductTypeId); } } else { deleteCommand.Parameters.AddWithValue("@OldProductTypeId", DBNull.Value); } if (ProductMaster.IsActive == true) { deleteCommand.Parameters.AddWithValue("@OldisActive", ProductMaster.IsActive); } else { deleteCommand.Parameters.AddWithValue("@OldisActive", DBNull.Value); } deleteCommand.Parameters.Add("@ReturnValue", System.Data.SqlDbType.Int); deleteCommand.Parameters["@ReturnValue"].Direction = ParameterDirection.Output; try { connection.Open(); deleteCommand.ExecuteNonQuery(); int count = System.Convert.ToInt32(deleteCommand.Parameters["@ReturnValue"].Value); if (count > 0) { return(true); } else { return(false); } } catch (SqlException) { return(false); } finally { connection.Close(); } }
public ActionResult Add(ProductMaster objProductMaster) { string errorMessage = string.Empty; try { if (ModelState.IsValid) { if (objProductMaster.ProductID > 0) { if (Session["ExistingImg"] != null) { List <DataAccessLayer.Image> existingImageList = new List <DataAccessLayer.Image>(); existingImageList = ((ICollection <DataAccessLayer.Image>)Session["ExistingImg"]) .Select(x => new DataAccessLayer.Image { ImageID = x.ImageID, ImageName = x.ImageName, ImagePath = x.ImagePath, ProductID = x.ProductID }).ToList(); objProductMaster.Images = existingImageList; } Session.Remove("Images"); Session.Remove("ExistingImg"); if (imageUrlList != null) { var imageList = new List <DataAccessLayer.Image>(); foreach (var image in imageUrlList) { var img = new DataAccessLayer.Image { ProductID = objProductMaster.ProductID }; img.ImageName = image.Key; img.ImagePath = GetUploadImageUrl(image.Value, objProductMaster.ProductCode); objProductMaster.Images.Add(img); } } List <DataAccessLayer.Image> images = new List <DataAccessLayer.Image>(objProductMaster.Images); DataTable imgDataTable = ConversionHelper.ConvertToDataTable(images); imgDataTable.Columns.Remove("ProductMaster"); SqlParameter imgDetails = new SqlParameter { ParameterName = "ImgDetails", Value = imgDataTable, SqlDbType = SqlDbType.Structured, TypeName = " [dbo].[ImgTable]" }; SqlParameter productID = new SqlParameter { ParameterName = "ProductID", Value = objProductMaster.ProductID, SqlDbType = SqlDbType.BigInt }; SqlParameter productCode = new SqlParameter { ParameterName = "ProductCode", Value = objProductMaster.ProductCode, SqlDbType = SqlDbType.VarChar }; SqlParameter productName = new SqlParameter { ParameterName = "ProductName", Value = objProductMaster.ProductName, SqlDbType = SqlDbType.VarChar }; SqlParameter productTypeID = new SqlParameter { ParameterName = "ProductTypeID", Value = objProductMaster.ProductTypeID, SqlDbType = SqlDbType.Int }; SqlParameter weightInGms = new SqlParameter { ParameterName = "WeightInGms", Value = objProductMaster.WeightInGms, SqlDbType = SqlDbType.Decimal }; SqlParameter heightInInch = new SqlParameter { ParameterName = "HeightInInch", Value = objProductMaster.HeightInInch, SqlDbType = SqlDbType.VarChar }; if (objProductMaster.HeightInInch == null) { heightInInch.Value = DBNull.Value; } SqlParameter widthInInch = new SqlParameter { ParameterName = "WidthInInch", Value = objProductMaster.WidthInInch, SqlDbType = SqlDbType.VarChar }; if (objProductMaster.WidthInInch == null) { widthInInch.Value = DBNull.Value; } SqlParameter price = new SqlParameter { ParameterName = "Price", Value = objProductMaster.Price, SqlDbType = SqlDbType.Decimal }; SqlParameter isOffer = new SqlParameter { ParameterName = "IsOffer", Value = objProductMaster.IsOffer, SqlDbType = SqlDbType.Bit }; SqlParameter offerPrice = new SqlParameter { ParameterName = "OfferPrice", Value = objProductMaster.OfferPrice, SqlDbType = SqlDbType.Decimal }; if (objProductMaster.OfferPrice == null) { offerPrice.Value = DBNull.Value; } SqlParameter isActive = new SqlParameter { ParameterName = "IsActive", Value = objProductMaster.IsActive, SqlDbType = SqlDbType.Bit }; SqlParameter description = new SqlParameter { ParameterName = "Description", Value = objProductMaster.Description, SqlDbType = SqlDbType.VarChar }; SqlParameter occasionId = new SqlParameter { ParameterName = "OccasionId", Value = objProductMaster.OccasionId, SqlDbType = SqlDbType.Int }; if (objProductMaster.OccasionId == null) { occasionId.Value = DBNull.Value; } SqlParameter offerStartDate = new SqlParameter { ParameterName = "OfferStartDate", Value = objProductMaster.OfferStartDate, SqlDbType = SqlDbType.DateTime }; if (objProductMaster.OfferStartDate == null) { offerStartDate.Value = DBNull.Value; } SqlParameter offerEndDate = new SqlParameter { ParameterName = "OfferEndDate", Value = objProductMaster.OfferEndDate, SqlDbType = SqlDbType.DateTime }; if (objProductMaster.OfferEndDate == null) { offerEndDate.Value = DBNull.Value; } SqlParameter makingChargePercentage = new SqlParameter { ParameterName = "MakingChargePercentage", Value = objProductMaster.MakingChargePercentage, SqlDbType = SqlDbType.Decimal }; if (objProductMaster.MakingChargePercentage == null) { makingChargePercentage.Value = DBNull.Value; } SqlParameter makingCharge = new SqlParameter { ParameterName = "MakingCharge", Value = objProductMaster.MakingCharge, SqlDbType = SqlDbType.Decimal }; if (objProductMaster.MakingCharge == null) { makingCharge.Value = DBNull.Value; } SqlParameter isMakingChargePercentage = new SqlParameter { ParameterName = "IsMakingChargePercentage", Value = objProductMaster.IsMakingChargePercentage, SqlDbType = SqlDbType.Bit }; SqlParameter metalVariantId = new SqlParameter { ParameterName = "MetalVariantId", Value = objProductMaster.MetalVariantId, SqlDbType = SqlDbType.Int }; if (objProductMaster.MetalVariantId == null) { metalVariantId.Value = DBNull.Value; } SqlParameter gemVariantId = new SqlParameter { ParameterName = "GemVariantId", Value = objProductMaster.GemVariantId, SqlDbType = SqlDbType.Int }; if (objProductMaster.GemVariantId == null) { gemVariantId.Value = DBNull.Value; } SqlParameter amazonUrl = new SqlParameter { ParameterName = "AmazonUrl", Value = objProductMaster.AmazonUrl, SqlDbType = SqlDbType.VarChar }; if (objProductMaster.AmazonUrl == null) { amazonUrl.Value = DBNull.Value; } SqlParameter eBayUrl = new SqlParameter { ParameterName = "eBayUrl", Value = objProductMaster.eBayUrl, SqlDbType = SqlDbType.VarChar }; if (objProductMaster.eBayUrl == null) { eBayUrl.Value = DBNull.Value; } object[] parameters = new object[] { productID, productCode, productName, productTypeID, weightInGms, heightInInch, widthInInch, price, isOffer, offerPrice, isActive, description, occasionId, offerStartDate, offerEndDate, makingChargePercentage, makingCharge, isMakingChargePercentage, metalVariantId, gemVariantId, imgDetails, amazonUrl, eBayUrl }; objAsopalavDBEntities.Database.ExecuteSqlCommand("EXEC [dbo].[AddUpdateProduct] @ProductID, @ProductCode, @ProductName ,@ProductTypeID, @WeightInGms, @HeightInInch, @WidthInInch, @Price, @IsOffer, @OfferPrice, @IsActive, @Description, @OccasionId, @OfferStartDate, @OfferEndDate, @MakingChargePercentage, @MakingCharge, @IsMakingChargePercentage, @MetalVariantId, @GemVariantId,@ImgDetails,@AmazonUrl,@eBayUrl", parameters); } else { var metalName = (objAsopalavDBEntities.MetalVariants.Where(m => m.MetalVariantId == objProductMaster.MetalVariantId) .Select(m => m.Name)).FirstOrDefault(); string gemName = (objAsopalavDBEntities.GemVariants.Where(m => m.GemVariantId == objProductMaster.GemVariantId) .Select(m => m.Name)).FirstOrDefault(); if (!(String.IsNullOrEmpty(gemName))) { var prodCountG = objAsopalavDBEntities.ProductMasters.Where(p => p.MetalVariant.Name == metalName && p.GemVariant.Name == gemName && p.IsActive == true).Count(); objProductMaster.ProductCode = "AJ" + metalName[0] + gemName[0] + "000" + Convert.ToString(prodCountG + 1); } else { var prodCountM = objAsopalavDBEntities.ProductMasters.Where(p => p.MetalVariant.Name == metalName && p.IsActive == true).Count(); objProductMaster.ProductCode = "AJ" + metalName[0] + "000" + Convert.ToString(prodCountM + 1); } objProductMaster.CreationDate = DateTime.Now; objAsopalavDBEntities.ProductMasters.Add(objProductMaster); if (imageUrlList != null) { var imageList = new List <DataAccessLayer.Image>(); foreach (var image in imageUrlList) { var img = new DataAccessLayer.Image { ProductID = objProductMaster.ProductID }; img.ImageName = image.Key; img.ImagePath = GetUploadImageUrl(image.Value, objProductMaster.ProductCode); imageList.Add(img); } objProductMaster.Images = imageList; } objAsopalavDBEntities.SaveChanges(); imageUrlList.Clear(); } TempData["isProductSaved"] = "true"; TempData["ProductSaveMsg"] = "Record Saved. (Item Name : " + objProductMaster.ProductCode + " )"; return(RedirectToAction("Index")); } else { foreach (var item in ModelState.Keys) { if (ModelState[item].Errors.Count > 0) { errorMessage += ModelState[item].Errors.ToList()[0].ErrorMessage; TempData["isProductSaved"] = "false"; TempData["ProductSaveMsg"] = errorMessage; } } } } catch (Exception ex) { TempData["isSaved"] = "false"; if (ex.InnerException != null) { TempData["ProductSaveMsg"] = ex.InnerException.Message; } else { TempData["ProductSaveMsg"] = ex.Message; } } ViewData["ProductTypeID"] = GetProductTypeList(); ViewData["OccasionId"] = GetOccasionList(); ViewData["MetalVariantId"] = GetMetalList(); ViewData["GemVariantId"] = GetGemList(); return(View(objProductModel)); }
public ActionResult Create() { var Product = new ProductMaster(); return(View(Product)); }
public ProductMasterInsertDataParameters(ProductMaster pro) { ProductMaster = pro; Build(); }
public IHttpActionResult UpdateProduct(ProductMaster product) { return(Ok(product_service.UpdateProduct(product))); }
public IHttpActionResult AddNewProduct(ProductMaster product) { return(Ok(product_service.AddNewProduct(product))); }
public ProductMasterSelectByIDDataParameters(ProductMaster val) { PMaster = val; Build(); }
public HttpResponseMessage GetProducts(UserMobileNumber objUserMobileNumber) { try { ProductMaster objListProductMaster = new ProductMaster(); List <Product> objListProduct = new List <Product>(); string mobileNumber = objUserMobileNumber.MobileNumber; //get state from user table var getUser = (from user in dbContext.UserInfo where user.MobileNumber == mobileNumber select user).FirstOrDefault(); if (!string.IsNullOrEmpty(getUser.State)) { //For getting list of product from the table. var getProducts = (from product in dbContext.Product_Master where product.PrdState == getUser.State select product).ToList(); if (getProducts != null) { foreach (var i in getProducts) { Product objProduct = new Product() { SkuId = i.SkuId, SkuName = i.SkuName, ItemCode = i.ItemCode, Description = i.Description, Price = i.Price, CurrentQuantity = i.CurrentQuantity, SkuCreatedDate = Convert.ToString(i.SkuCreatedDate), GSTPercent = i.GSTPercent, ImageUrl = i.ImageUrl, MinQuantittyToBook = i.MinQuantittyToBook, MaxQuantittyToBook = i.MaxQuantittyToBook, PrdCompanyName = i.PrdCompanyName, AllowSAPOrder = i.AllowSAPOrder, PrdState = i.PrdState, Status = i.Status, }; objListProduct.Add(objProduct); } objListProductMaster.Products = objListProduct; return(Request.CreateResponse(HttpStatusCode.OK, objListProductMaster)); } objResponse.Message = "Products not available please update profile"; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } else { //For getting list of product from the table. var getProducts = (from product in dbContext.Product_Master select product).ToList(); if (getProducts != null) { foreach (var i in getProducts) { Product objProduct = new Product() { SkuId = i.SkuId, SkuName = i.SkuName, ItemCode = i.ItemCode, Description = i.Description, Price = i.Price, CurrentQuantity = i.CurrentQuantity, SkuCreatedDate = Convert.ToString(i.SkuCreatedDate), GSTPercent = i.GSTPercent, ImageUrl = i.ImageUrl, MinQuantittyToBook = i.MinQuantittyToBook, MaxQuantittyToBook = i.MaxQuantittyToBook, PrdCompanyName = i.PrdCompanyName, AllowSAPOrder = i.AllowSAPOrder, PrdState = i.PrdState, Status = i.Status, }; objListProduct.Add(objProduct); } objListProductMaster.Products = objListProduct; return(Request.CreateResponse(HttpStatusCode.OK, objListProductMaster)); } objResponse.Message = "Product not found"; return(Request.CreateResponse(HttpStatusCode.OK, objResponse)); } } catch (Exception ex) { Log.Info(Convert.ToString(ex.InnerException)); Log.Info(ex.Message); objCommonClasses.InsertExceptionDetails(ex, "MasterController", "GetProducts"); return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex.Message)); } }
public void UpdateProductMaster(ProductMaster Product) { _ProductRepository.Update(Product); }
public ResponseMessage AddNewProduct(ProductMaster product) { return(productdao.AddNewProduct(product)); }
public ProductVariantBuilder ForMaster(ProductMaster master) { master.Add(Item); return(MySelf); }
/// <summary> /// To get the product master list.. /// </summary> /// <param name="users"></param> /// <returns></returns> public DataTable GetProductMaster(ProductMaster product_master) { var DbManager = new DBManager("DBConnection"); return(DbManager.GetDataTable(_StoredProcedures.GetProductMaster_SP, CommandType.StoredProcedure, _AdminMasterIRepository.AddParametersProductMasterGet(product_master))); }
protected void Page_UnLoad(object sender, EventArgs e) { objCommonClass = null; objProductMaster = null; }
public ActionResult Create(ProductMaster p) { ctx.ProductMaster.Add(p); ctx.SaveChanges(); return(RedirectToAction("Index")); }
public ApplicationResult Product_Update(ProductMaster objProductBo) { try { pSqlParameter = new SqlParameter[14]; pSqlParameter[0] = new SqlParameter("@PK_Id", SqlDbType.Int); pSqlParameter[0].Direction = ParameterDirection.Input; pSqlParameter[0].Value = objProductBo.PK_Id; pSqlParameter[1] = new SqlParameter("@Code", SqlDbType.VarChar); pSqlParameter[1].Direction = ParameterDirection.Input; pSqlParameter[1].Value = objProductBo.Code; pSqlParameter[2] = new SqlParameter("@CreatedBy", SqlDbType.Int); pSqlParameter[2].Direction = ParameterDirection.Input; pSqlParameter[2].Value = objProductBo.CreatedBy; pSqlParameter[3] = new SqlParameter("@CreatedDate", SqlDbType.DateTime); pSqlParameter[3].Direction = ParameterDirection.Input; pSqlParameter[3].Value = objProductBo.CreatedDate; pSqlParameter[4] = new SqlParameter("@ModifiedBy", SqlDbType.Int); pSqlParameter[4].Direction = ParameterDirection.Input; pSqlParameter[4].Value = objProductBo.ModifiedBy; pSqlParameter[5] = new SqlParameter("@ModifiedDate", SqlDbType.DateTime); pSqlParameter[5].Direction = ParameterDirection.Input; pSqlParameter[5].Value = objProductBo.ModifiedDate; pSqlParameter[6] = new SqlParameter("@Status", SqlDbType.Bit); pSqlParameter[6].Direction = ParameterDirection.Input; pSqlParameter[6].Value = objProductBo.Status; pSqlParameter[7] = new SqlParameter("@Description", SqlDbType.VarChar); pSqlParameter[7].Direction = ParameterDirection.Input; pSqlParameter[7].Value = objProductBo.Description; pSqlParameter[8] = new SqlParameter("@SellingRate", SqlDbType.Decimal); pSqlParameter[8].Direction = ParameterDirection.Input; pSqlParameter[8].Value = objProductBo.SellingRate; pSqlParameter[9] = new SqlParameter("@PurchaseRate", SqlDbType.Decimal); pSqlParameter[9].Direction = ParameterDirection.Input; pSqlParameter[9].Value = objProductBo.PurchaseRate; pSqlParameter[10] = new SqlParameter("@UnitName", SqlDbType.VarChar); pSqlParameter[10].Direction = ParameterDirection.Input; pSqlParameter[10].Value = objProductBo.UnitName; pSqlParameter[11] = new SqlParameter("@ShopId", SqlDbType.BigInt); pSqlParameter[11].Direction = ParameterDirection.Input; pSqlParameter[11].Value = objProductBo.ShopId; pSqlParameter[12] = new SqlParameter("@ProductName", SqlDbType.VarChar); pSqlParameter[12].Direction = ParameterDirection.Input; pSqlParameter[12].Value = objProductBo.ProductName; pSqlParameter[13] = new SqlParameter("@ImagePath", SqlDbType.VarChar); pSqlParameter[13].Direction = ParameterDirection.Input; pSqlParameter[13].Value = objProductBo.ImagePath; sSql = "usp_tbl_ProductMasters_Update"; int iResult = Database.ExecuteNonQuery(CommandType.StoredProcedure, sSql, pSqlParameter); if (iResult > 0) { ApplicationResult objResults = new ApplicationResult(); objResults.status = ApplicationResult.CommonStatusType.SUCCESS; return(objResults); } else { ApplicationResult objResults = new ApplicationResult(); objResults.status = ApplicationResult.CommonStatusType.FAILURE; return(objResults); } } catch (Exception ex) { throw ex; } finally { objProductBo = null; } }
public async void Add([FromBody] ProductMaster product) { product.Id = Guid.NewGuid(); await _dataBaseHandler.AddAsync(product); }
public decimal ApplyPromotionOffer(List <Products> selectedProducts) { decimal total = 0; var products = ProductMaster.GetProducts(); var productOffers = PromotionOfferMaster.GetProductOffers(); var processedProducts = new List <int>(); foreach (var item in selectedProducts) { if (!processedProducts.Contains(item.ProductId)) { var availableOffers = productOffers.Where(s => s.BaseProductId == item.ProductId); if (availableOffers.Any()) { foreach (var availableOffer in availableOffers) { if (availableOffer.Products.Count > 1) { var applicableOffer = availableOffer.Products.FirstOrDefault(s => s.ProductId == item.ProductId && s.Quantity <= item.Quantity); if (applicableOffer != null) { var selectedProductIds = selectedProducts.Select(s => s.ProductId); var otherOfferProducts = availableOffer.Products.Where(s => s.ProductId != item.ProductId && selectedProductIds.Contains(s.ProductId)); decimal comboTotal = 0; if (otherOfferProducts.Any()) { var noOfBaseApplicableOffers = item.Quantity / applicableOffer.Quantity; var minAllowedOffer = noOfBaseApplicableOffers; var flag = false; foreach (var otherOfferProd in otherOfferProducts) { var otherSelectedProducts = selectedProducts.FirstOrDefault(s => s.ProductId == otherOfferProd.ProductId && s.Quantity >= otherOfferProd.Quantity); if (otherSelectedProducts == null) { flag = false; break; } else { var noOfApplicableOffers = otherSelectedProducts.Quantity / otherOfferProd.Quantity; var remainingQuantity = otherSelectedProducts.Quantity % otherOfferProd.Quantity; if (minAllowedOffer > noOfApplicableOffers) { minAllowedOffer = noOfApplicableOffers; } remainingQuantity = otherSelectedProducts.Quantity >= otherOfferProd.Quantity * minAllowedOffer ? otherSelectedProducts.Quantity - otherOfferProd.Quantity * minAllowedOffer : otherSelectedProducts.Quantity; var productDetail = products.Find(s => s.ProductId == otherOfferProd.ProductId); var cost = remainingQuantity * productDetail.ProductPrice; comboTotal += cost; flag = true; } } if (flag) { var remainingQuantity = item.Quantity >= applicableOffer.Quantity * minAllowedOffer ? item.Quantity - applicableOffer.Quantity * minAllowedOffer : item.Quantity; var productDetail = products.Find(s => s.ProductId == item.ProductId); var cost = (minAllowedOffer * availableOffer.OfferPrice) + (remainingQuantity * productDetail.ProductPrice); comboTotal += cost; total += comboTotal; var processedItem = otherOfferProducts.Select(s => s.ProductId); processedProducts.AddRange(processedItem); processedProducts.Add(item.ProductId); } else { var productDetail = products.FirstOrDefault(s => s.ProductId == item.ProductId); if (productDetail != null) { var cost = item.Quantity * productDetail.ProductPrice; total += cost; processedProducts.Add(item.ProductId); } } } else { var productDetail = products.FirstOrDefault(s => s.ProductId == item.ProductId); if (productDetail != null) { var cost = item.Quantity * productDetail.ProductPrice; total += cost; processedProducts.Add(item.ProductId); } } } } else { var applicableOffer = availableOffer.Products.FirstOrDefault(s => s.Quantity <= item.Quantity); if (applicableOffer != null) { var noOfApplicableOffers = item.Quantity / applicableOffer.Quantity; var remainingQuantity = item.Quantity % applicableOffer.Quantity; var productDetail = products.Find(s => s.ProductId == item.ProductId); var cost = (noOfApplicableOffers * availableOffer.OfferPrice) + (remainingQuantity * productDetail.ProductPrice); total += cost; } else { var productDetail = products.FirstOrDefault(s => s.ProductId == item.ProductId); if (productDetail != null) { var cost = item.Quantity * productDetail.ProductPrice; total += cost; } } processedProducts.Add(item.ProductId); } if (processedProducts.Contains(item.ProductId)) { break; } } } else { var productDetail = products.FirstOrDefault(s => s.ProductId == item.ProductId); if (productDetail != null) { var cost = item.Quantity * productDetail.ProductPrice; total += cost; processedProducts.Add(item.ProductId); } } } } return(total); }
public async void UpdateProduct(Guid id, [FromBody] ProductMaster product) { //var id = (await _dataBaseHandler.FirstOrDefaultAsync<ProductMaster>(p => p.PID == pId)).Id; //product.Id = id; await _dataBaseHandler.UpdateAsync(product); }
protected void ProdDisplayGrid_RowCommand(object sender, GridViewCommandEventArgs e) { if ((e.CommandName == "displayPopup")) { Session["prod_ID"] = e.CommandArgument; Response.Redirect("GetExpiryDetails.aspx"); } else if ((e.CommandName == "EditVal")) { GridViewRow gvr = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); int RowIndex = gvr.RowIndex; ProductMaster product = new ProductMaster(); product.ProductID = int.Parse(((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_id")).Text); product.ProductName = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_Name")).Text; product.ProductOrgID = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_org_id")).Text; product.Manufacturer = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_Man")).Text; product.ProductCode = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_Code")).Text; product.ProductDescription = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_Desc")).Text; product.ProductSelection = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_sel")).Text; product.GenericName = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_Gen")).Text; product.ProductType = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_Type")).Text; product.BinNumber = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_bNum")).Text; product.Control = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_con")).Text; product.Expiry = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_exp")).Text; product.MeasureQuantity = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_mQTY")).Text; product.MeasureType = ((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_mType")).Text; int res, res2, res4, res6, res7; float res3, res5; if (int.TryParse((((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_qUnit")).Text), out res)) { product.QuanityUnit = res; } else { product.QuanityUnit = 0; } if (int.TryParse((((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_line")).Text), out res6)) { product.LineID = res6; } if (int.TryParse((((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_Disc")).Text), out res7)) { product.MaxDiscount = res7; } if (float.TryParse((((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_SP")).Text), out res3)) { product.SalePrice = res3; } if (float.TryParse((((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_CP")).Text), out res5)) { product.CostPrice = res5; } if (int.TryParse((((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_tsh")).Text), out res2)) { product.ThreshHold = res2; } if (int.TryParse((((Label)ProdDisplayGrid.Rows[RowIndex].FindControl("lblProd_subCatID")).Text), out res4)) { product.SubCategoryID = res4; } ucProdEdit.CurrentSource = product; ucProdEdit.IsAdd = false; mpeEditProduct.Show(); // LoadDataToEditPopup(int.Parse((string)e.CommandArgument)); } }
private void BtnInsertUpdate_Click(object sender, EventArgs e) { try { if (DropDownItemName.SelectedIndex <= 0) { messageShow.singlemsgtext("Please select the Item Name"); DropDownItemName.Focus(); return; } if (string.IsNullOrEmpty(TxtProductName.Text.ToString())) { messageShow.singlemsgtext("Product name should not be empty"); TxtProductName.Focus(); return; } if (string.IsNullOrEmpty(TxtMinimumStockNotify.Text.ToString())) { messageShow.singlemsgtext("Minimum stock notification should not be empty"); TxtMinimumStockNotify.Focus(); return; } else { if (Convert.ToInt32(TxtMinimumStockNotify.Text.ToString()) < 0) { messageShow.singlemsgtext("Minimum stock notification should be greater than zero"); TxtMinimumStockNotify.Focus(); return; } } var product_master = new ProductMaster { ProductName = TxtProductName.Text.ToString(), MinimumStockNotification = Convert.ToInt32(TxtMinimumStockNotify.Text.ToString()), ItemCode = Convert.ToInt32(((KeyValuePair <string, string>)DropDownItemName.SelectedItem).Key.ToString()), ProductCode = ProductCode, OperationType = BtnInsertUpdate.Text.ToString() == "Save" ? 1 : 2 }; int id = _instanceRepository.InsertUpdateDeleteProductMaster(product_master); if (id >= 1) { messageShow.singlemsgtext(product_master.OperationType == 1 ? "New Product added successfully" : "Product updated successfully"); product_master.ProductName = ""; ResetControlles(); } else if (id == -1) { messageShow.singlemsgtext("The product name already exists, please try another name!"); } else { messageShow.singlemsgtext("Error in Product insert/update"); } } catch (Exception _exception) { CmC.InsertException(_exception); messageShow.singlemsgtext(CmC.ExceptionErrorMessage); } }
/// <summary> /// Add parameters while fetch or product search items /// </summary> /// <param name="users"></param> /// <returns></returns> public IDbDataParameter[] AddParametersProductMasterGet(ProductMaster product_master) { parameters.Clear(); parameters.Add(dbManager.CreateParameter("@ProductName", 150, product_master.ProductName, DbType.String)); return(parameters.ToArray()); }
// Masters Section private void ProductMaster_Click(object sender, RoutedEventArgs e) { ProductMaster product = new ProductMaster(); product.ShowDialog(); }
private ProductSaleQueryResponse LoadThresholdInfo(ProductSaleQueryResponse thresholdInfo, ProductMaster product) { var tenantConfig = _context.TenantConfigs.FirstOrDefault(m => m.TenantId == product.TenantId); if (tenantConfig != null) { thresholdInfo.ShowWarning = tenantConfig.AlertMinimumProductPrice; thresholdInfo.CanProceed = !tenantConfig.EnforceMinimumProductPrice; thresholdInfo.FailureMessage = tenantConfig.AlertMinimumPriceMessage; thresholdInfo.StopMessage = tenantConfig.EnforceMinimumPriceMessage; } return(thresholdInfo); }
public ResponseMessage UpdateProduct(ProductMaster product) { return(productdao.UpdateProduct(product)); }