public int EditConfirm(int productId, string productName, string productUnit, double productWeight, string productDes, string productNote, int productPrice, int dropCate, string fileName, int[] materialId, int[] materialQuantity) { try { ManageProductBusiness mpb = new ManageProductBusiness(); var productToUpdate = mpb.GetProductDetail(productId); string productCode = CreateProductCode(productName); var productList = mpb.GetActiveProduct(); if (!StringComparer.CurrentCultureIgnoreCase.Equals(productName, productToUpdate.ProductName)) { for (int i = 0; i < productList.Count; i++) { if (StringComparer.CurrentCultureIgnoreCase.Equals(productName, productList[i].ProductName)) { //string strURL = Request.UrlReferrer.AbsolutePath; //string URL = String.Format("{0}{1}{2}", strURL, "?ProductId=", productId); //TempData["Error"] = String.Format("{0}{1}", productName, " đã tồn tại"); return -4; } } } try { productPrice = Convert.ToInt32(productPrice.ToString().Replace(".", "")); mpb.EditProduct(productId, productName, productUnit, productWeight, productDes, productNote, productPrice, dropCate, productCode, fileName, materialId, materialQuantity); return 2; } catch (DataException) { return -5; } } catch (Exception) { return -5; } }
public int AddProduct(string productName, string productUnit, double productWeight, string productDes, string productNote, int productPrice, int dropCate, string fileName, int[] materialId, int[] materialQuantity) { try { ManageProductBusiness mpb = new ManageProductBusiness(); //Check that product name had existed var productList = mpb.GetActiveProduct(); string productCode = CreateProductCode(productName); for (int i = 0; i < productList.Count; i++) { if (StringComparer.CurrentCultureIgnoreCase.Equals(productName, productList[i].ProductName)) { //string strURL = Request.UrlReferrer.AbsolutePath; //TempData["Error"] = String.Format("{0}{1}", productName, " đã tồn tại"); return -4; } } productPrice = Convert.ToInt32(productPrice.ToString().Replace(".", "")); mpb.AddProduct(productName, productUnit, productWeight, productDes, productNote, productPrice, dropCate, productCode, fileName, materialId, materialQuantity); Session["ProductInfor"] = null; Session["Material"] = null; return 2; } catch (Exception) { return -5; } }