public JsonResult AddUpdate(Product_SubCategory_Property objProductCategory) { if (Session["LOGGEDIN"] != null) { try { if (objProductCategory.idx > 0) { objProductSubCategoryBLL = new Product_SubCategory_BLL(objProductCategory); if (objProductSubCategoryBLL.CheckForUpdate().Rows.Count > 0) { return(Json(new { data = "Already Exist ", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); //show error } else { objProductSubCategoryBLL = new Product_SubCategory_BLL(objProductCategory); bool flag = objProductSubCategoryBLL.Update(); return(Json(new { data = "Updated", success = flag, statuscode = 200 }, JsonRequestBehavior.AllowGet)); } } else { //objProductCategory.companyIdx = 1; objProductCategory.CreatedByUserIdx = Convert.ToInt32(Session["UID"].ToString()); objProductSubCategoryBLL = new Product_SubCategory_BLL(objProductCategory); if (objProductSubCategoryBLL.CheckForInsert().Rows.Count > 0) { return(Json(new { data = "Already Exist ", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); //show error } else { bool flag = objProductSubCategoryBLL.Insert(); return(Json(new { data = "Inserted", success = flag, statuscode = 200 }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { data = "Session Expired", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public ActionResult AddNewProductSubCategory(int?id) { if (Session["LOGGEDIN"] != null) { objProductCategoryProperty = new Product_SubCategory_Property(); objProductCategoryProperty.idx = Convert.ToInt32(id); //objProductCategoryProperty.branchIdx = 1;//It will have the value of session branchIdx objProductSubCategoryBLL = new Product_SubCategory_BLL(objProductCategoryProperty); DataTable dtt = objProductSubCategoryBLL.ViewAllCategories(); List <Product_Category_Property> catLST = new List <Product_Category_Property>(); foreach (DataRow dr in dtt.Rows) { Product_Category_Property objProductCat = new Product_Category_Property(); objProductCat.Category = dr["Category"].ToString(); objProductCat.idx = Convert.ToInt32(dr["idx"].ToString()); catLST.Add(objProductCat); } ViewBag.catLST = catLST; if (id != null && id != 0) { var dt = objProductSubCategoryBLL.GetById(id); //objProductCategoryProperty.companyIdx = 1; objProductCategoryProperty.idx = int.Parse(dt.Rows[0]["idx"].ToString()); objProductCategoryProperty.product_catIdx = int.Parse(dt.Rows[0]["product_catIdx"].ToString()); objProductCategoryProperty.subCategory = dt.Rows[0]["subCategory"].ToString(); objProductCategoryProperty.HS_CodeSub = dt.Rows[0]["HS_CodeSub"].ToString(); //objProductCategoryProperty.firstName = dt.Rows[0]["firstName"].ToString(); //objProductCategoryProperty.lastName = dt.Rows[0]["lastName"].ToString(); //objProductCategoryProperty.CNIC = (dt.Rows[0]["CNIC"].ToString()); //objProductCategoryProperty.cellNumber = (dt.Rows[0]["cellNumber"].ToString()); //objProductCategoryProperty.loginId = (dt.Rows[0]["loginId"].ToString()); //objProductCategoryProperty.password = dt.Rows[0]["password"].ToString(); } return(PartialView("_AddNewProductSubCategory", objProductCategoryProperty)); } else { return(Json(new { data = "Session Expired", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public JsonResult DeleteProductSubCat(int?id) { if (Session["LOGGEDIN"] != null) { try { if (id > 0) { Product_SubCategory_Property branchProperty = new Product_SubCategory_Property(); branchProperty.idx = int.Parse(id.ToString()); objProductSubCategoryBLL = new Product_SubCategory_BLL(id); Product_SubCategory_BLL branhcBll = new Product_SubCategory_BLL(branchProperty); var flag1 = branhcBll.Delete(id); //if (flag1.Rows.Count > 0) //{ if (true) { bool flag = objProductSubCategoryBLL.Delete(id); return(Json(new { data = "Deleted", success = flag, statuscode = 200 }, JsonRequestBehavior.AllowGet)); } //else //{ // return Json(new { data = "Mian Branch Cannot be Delete ", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet); //} //} // return Json(new { data = "Process Completed ", success = true, statuscode = 200 }, JsonRequestBehavior.AllowGet); } else { return(Json(new { data = "Error Occur", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { data = "Session Expired", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public JsonResult AddUpdate(Product_SubCategory_Property objProductCategory) { if (Session["LOGGEDIN"] != null) { try { if (objProductCategory.idx > 0) { //objProductCategory.lastModifiedByUserIdx = 1; //objProductCategory.lastModificationDate = DateTime.Now.ToString("dd/MM/yyyy"); objProductSubCategoryBLL = new Product_SubCategory_BLL(objProductCategory); bool flag = objProductSubCategoryBLL.Update(); return(Json(new { data = "Updated", success = flag, statuscode = 200 }, JsonRequestBehavior.AllowGet)); } else { //objProductCategory.companyIdx = 1; objProductCategory.CreatedByUserIdx = Convert.ToInt32(Session["UID"].ToString()); objProductSubCategoryBLL = new Product_SubCategory_BLL(objProductCategory); //if (objProductCategory.isMainBranch == 1) //{ // var check = objProductCategory.MainBranch(); // if (check.Rows.Count > 0) // { // return Json(new { data = "Main Branch Already Exist", success = false, statuscode = 500 }, JsonRequestBehavior.AllowGet); // } //} bool flag = objProductSubCategoryBLL.Insert(); return(Json(new { data = "Inserted", success = flag, statuscode = 200 }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { data = "Session Expired", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetAllProductSubCategories() { if (Session["LOGGEDIN"] != null) { try { objProductCategoryProperty = new Product_SubCategory_Property(); //objProductCategoryProperty.branchIdx = 1;//user logged in session branchIdx objProductSubCategoryBLL = new Product_SubCategory_BLL(objProductCategoryProperty); var Data = JsonConvert.SerializeObject(objProductSubCategoryBLL.ViewAll()); return(Json(new { data = Data, success = true, statuscode = 200, count = Data.Length }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { data = "Session Expired", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public Product_SubCategory_BLL(Product_SubCategory_Property objProduct_Property) { objProductSubCategoryProperty = objProduct_Property; }
public ActionResult AddNewProduct(int?id) { if (Session["LOGGEDIN"] != null) { objProductProperty = new Product_Property(); objProductProperty.idx = Convert.ToInt32(id); //objProductProperty.branchIdx = 1;//It will have the value of session branchIdx objProductBLL = new Product_BLL(objProductProperty); DataTable categories = objProductBLL.ddlCategory(); List <Product_Category_Property> catLST = new List <Product_Category_Property>(); DataTable subCategories = objProductBLL.ddlSubCategory(); List <Product_SubCategory_Property> subCatLST = new List <Product_SubCategory_Property>(); DataTable productTypes = objProductBLL.ddlProductType(); List <Product_Type_Property> productTypeLST = new List <Product_Type_Property>(); DataTable units = objProductBLL.ddlUnit(); List <itemUnit_Property> unitLST = new List <itemUnit_Property>(); foreach (DataRow dr in categories.Rows) { Product_Category_Property objProductCat = new Product_Category_Property(); objProductCat.Category = dr["category"].ToString(); objProductCat.idx = Convert.ToInt32(dr["idx"].ToString()); catLST.Add(objProductCat); } ViewBag.catLST = catLST; foreach (DataRow dr in subCategories.Rows) { Product_SubCategory_Property objProductCat = new Product_SubCategory_Property(); objProductCat.subCategory = dr["subCategory"].ToString(); objProductCat.idx = Convert.ToInt32(dr["idx"].ToString()); subCatLST.Add(objProductCat); } ViewBag.subCatLST = subCatLST; foreach (DataRow dr in productTypes.Rows) { Product_Type_Property objProductCat = new Product_Type_Property(); objProductCat.productType = dr["productType"].ToString(); objProductCat.idx = Convert.ToInt32(dr["idx"].ToString()); productTypeLST.Add(objProductCat); } ViewBag.productTypeLST = productTypeLST; foreach (DataRow dr in units.Rows) { itemUnit_Property objProductCat = new itemUnit_Property(); objProductCat.itemUnit = dr["itemUnit"].ToString(); objProductCat.idx = Convert.ToInt32(dr["idx"].ToString()); unitLST.Add(objProductCat); } ViewBag.unitLST = unitLST; if (id != null && id != 0) { decimal cp, sp, pt; var dt = objProductBLL.GetById(id); //objProductProperty.companyIdx = 1; objProductProperty.idx = int.Parse(dt.Rows[0]["idx"].ToString()); objProductProperty.productTypeIdx = int.Parse(dt.Rows[0]["productTypeIdx"].ToString()); objProductProperty.productCatIdx = int.Parse(dt.Rows[0]["productCatIdx"].ToString()); objProductProperty.productSubCatIdx = int.Parse(dt.Rows[0]["productSubCatIdx"].ToString()); objProductProperty.unitIdx = int.Parse(dt.Rows[0]["unitIdx"].ToString()); objProductProperty.HSCODE = (dt.Rows[0]["HSCODE"].ToString()); objProductProperty.itemCode = (dt.Rows[0]["itemCode"].ToString()); objProductProperty.itemName = (dt.Rows[0]["itemName"].ToString()); objProductProperty.description = (dt.Rows[0]["description"].ToString()); //objProductProperty.costPrice = 0.00m; string costPrice = (dt.Rows[0]["costPrice"].ToString()); decimal.TryParse(costPrice, out cp); objProductProperty.costPrice = cp; string salePrice = (dt.Rows[0]["salePrice"].ToString()); decimal.TryParse(salePrice, out sp); objProductProperty.salePrice = sp; string productTax = (dt.Rows[0]["productTax"].ToString()); decimal.TryParse(productTax, out pt); objProductProperty.productTax = pt; //objProductProperty.product_catIdx = int.Parse(dt.Rows[0]["product_catIdx"].ToString()); //objProductProperty.subCategory = dt.Rows[0]["subCategory"].ToString(); //objProductProperty.HS_CodeSub = dt.Rows[0]["HS_CodeSub"].ToString(); ////objProductProperty.firstName = dt.Rows[0]["firstName"].ToString(); //objProductProperty.lastName = dt.Rows[0]["lastName"].ToString(); //objProductProperty.CNIC = (dt.Rows[0]["CNIC"].ToString()); //objProductProperty.cellNumber = (dt.Rows[0]["cellNumber"].ToString()); //objProductProperty.loginId = (dt.Rows[0]["loginId"].ToString()); //objProductProperty.password = dt.Rows[0]["password"].ToString(); } else { LP_GenerateTransNumber_Property objtrans = new LP_GenerateTransNumber_Property(); objtrans.TableName = "products"; objtrans.Identityfieldname = "idx"; objtrans.userid = Session["UID"].ToString(); objProductProperty.itemCode = objProductBLL.GenerateProductCode(objtrans); } return(PartialView("_AddNewProduct", objProductProperty)); } else { return(RedirectToAction("Login", "Account")); } }
//private ErrorTracer objErrorTrace; public Product_SubCategory_DAL(Product_SubCategory_Property objProduct_SubCategory) { objProductSubCategory = objProduct_SubCategory; }