public static List <SelectListItem> getManufacturer(Int64 manufid) { List <SelectListItem> lstmanufacturer = new List <SelectListItem>(); DataTable dtcustomer = new DataTable(); dtcustomer = ProductMasterData.ManufactureList(); foreach (DataRow dr in dtcustomer.Rows) { if (manufid.ToString() == dr["ManufacturerId"].ToString()) { lstmanufacturer.Add(new SelectListItem { Value = dr["ManufacturerId"].ToString(), Text = dr["manufacturerdesc"].ToString(), Selected = true }); } else { lstmanufacturer.Add(new SelectListItem { Value = dr["ManufacturerId"].ToString(), Text = dr["manufacturerdesc"].ToString() }); } } return(lstmanufacturer.ToList()); }
public static List <SelectListItem> getProductTypeList(Int64 ProductTypeId) { List <SelectListItem> lstproducttype = new List <SelectListItem>(); DataTable dtcustomer = new DataTable(); dtcustomer = ProductMasterData.ProductTypeList(); lstproducttype.Add(new SelectListItem { Value = "0", Text = "---Select---" }); foreach (DataRow dr in dtcustomer.Rows) { if (ProductTypeId.ToString() == dr["ProductTypeId"].ToString()) { lstproducttype.Add(new SelectListItem { Value = dr["ProductTypeId"].ToString(), Text = dr["ProductType"].ToString(), Selected = true }); } else { lstproducttype.Add(new SelectListItem { Value = dr["ProductTypeId"].ToString(), Text = dr["ProductType"].ToString() }); } } return(lstproducttype.ToList()); }
public ActionResult Edit(int Productid, ProductMaster prdmaster) { ProductMaster oProdMaster = new ProductMaster(); Int64 pProductId = System.Convert.ToInt64(prdmaster.ProductId); oProdMaster = ProductMasterData.Select_Record(pProductId); if (ModelState.IsValid) { bool bSucess = false; bSucess = ProductMasterData.Update(oProdMaster, prdmaster); if (bSucess == true) { ViewData["resultUpdate"] = "1"; return(RedirectToAction("Index")); } else { ViewData["resultUpdate"] = "0"; ModelState.AddModelError("", "Can Not Update"); } } return(View(prdmaster)); }
public static List <SelectListItem> SelectCategoryfrCustomer(Int64 pCustId, Int64 pCategoryId) { List <SelectListItem> lstcategory = new List <SelectListItem>(); DataTable dtcategory = new DataTable(); dtcategory = ProductMasterData.SelectCategoryForCustomer(pCustId); lstcategory.Add(new SelectListItem { Value = "0", Text = "---Select---" }); foreach (DataRow dr in dtcategory.Rows) { if (pCategoryId.ToString() == dr["ProdCatId"].ToString()) { lstcategory.Add(new SelectListItem { Value = dr["ProdCatId"].ToString(), Text = dr["ProdCatDesc"].ToString(), Selected = true }); } else { lstcategory.Add(new SelectListItem { Value = dr["ProdCatId"].ToString(), Text = dr["ProdCatDesc"].ToString() }); } } return(lstcategory.ToList()); }
public static List <SelectListItem> getCustomers(Int64 pCustId) { List <SelectListItem> lstcustomers = new List <SelectListItem>(); DataTable dtcustomer = new DataTable(); dtcustomer = ProductMasterData.SelectCustomer(); lstcustomers.Add(new SelectListItem { Value = "0", Text = "---Select---" }); foreach (DataRow dr in dtcustomer.Rows) { if (pCustId.ToString() == dr["CustId"].ToString()) { lstcustomers.Add(new SelectListItem { Value = dr["CustId"].ToString(), Text = dr["Custname"].ToString(), Selected = true }); } else { lstcustomers.Add(new SelectListItem { Value = dr["CustId"].ToString(), Text = dr["Custname"].ToString() }); } } return(lstcustomers.ToList()); }
public ActionResult Create(ProductMaster prdmaster) { if (ModelState.IsValid) { try { bool bSucess = false; prdmaster.ProductId = 0; bSucess = ProductMasterData.Add(prdmaster); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Insert"); return(View()); } } catch { return(View()); } } else { return(View()); } }
// GET: ProductMaster/Edit/5 public ActionResult Edit(Int64 Productid) { ViewData["lstManufacturer"] = getManufacturer(Productid); ViewData["lstProductType"] = getProductTypeList(Productid); ProductMaster ProductMaster = new ProductMaster(); ProductMaster = ProductMasterData.Select_Record(Productid); if (ProductMaster == null) { return(HttpNotFound()); } return(View(ProductMaster)); }
// GET: ProductMaster/Delete/5 public ActionResult Delete(Int64?Productid) { if (Productid == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductMasterDetail ProductMasterDetail = new ProductMasterDetail(); Int64 pProductId = System.Convert.ToInt64(Productid); ProductMasterDetail = ProductMasterData.Select_Record_Detail(pProductId); if (ProductMasterDetail == null) { return(HttpNotFound()); } return(View(ProductMasterDetail)); }
public ActionResult Delete(Int64 productId, FormCollection collection) { ProductMaster ProductMaster = new ProductMaster(); Int64 pCustId = System.Convert.ToInt64(productId); ProductMaster = ProductMasterData.Select_Record(pCustId); bool bSucess = false; bSucess = ProductMasterData.Delete(ProductMaster); if (bSucess == true) { return(RedirectToAction("Index")); } else { ModelState.AddModelError("", "Can Not Delete"); } return(null); }
public static List <SelectListItem> getBlankCategory(Int64 pCustId) { List <SelectListItem> lstcategory = new List <SelectListItem>(); DataTable dtcustomer = new DataTable(); dtcustomer = ProductMasterData.SelectCustomer(); lstcategory.Add(new SelectListItem { Value = "0", Text = "---Select---" }); /* foreach (DataRow dr in dtcustomer.Rows) * { * lstcustomers.Add(new SelectListItem * { * Value = dr["CustId"].ToString(), * Text = dr["Custname"].ToString() * }); * }*/ return(lstcategory.ToList()); }
public ActionResult Index1(string sortOrder, String SearchField, String SearchCondition, String SearchText, String Export, int?PageSize, int?page, string command) { DataTable dtProdMasterAll = new DataTable(); if (command == "Clear") { SearchField = null; SearchCondition = null; SearchText = null; Session["SearchField"] = null; Session["SearchCondition"] = null; Session["SearchText"] = null; } else if (command == "Add New Record") { return(RedirectToAction("Create")); } else if (command == "Export") { Session["Export"] = Export; } else if (command == "Search" | command == "Page Size") { if (!string.IsNullOrEmpty(SearchText)) { Session["SearchField"] = SearchField; Session["SearchCondition"] = SearchCondition; Session["SearchText"] = SearchText; } } if (command == "Page Size") { Session["PageSize"] = PageSize; } ViewData["SearchFields"] = GetFields1((Session["SearchField"] == null ? "Product Id" : Convert.ToString(Session["SearchField"]))); ViewData["SearchConditions"] = Library.GetConditions((Session["SearchCondition"] == null ? "Contains" : Convert.ToString(Session["SearchCondition"]))); ViewData["SearchText"] = Session["SearchText"]; ViewData["Exports"] = Library.GetExports((Session["Export"] == null ? "Pdf" : Convert.ToString(Session["Export"]))); ViewData["PageSizes"] = Library.GetPageSizes(); ViewData["CurrentSort"] = sortOrder; ViewData["ModelSortParm"] = sortOrder == "Model_asc" ? "Model_desc" : "Model_asc"; ViewData["lstCustomers"] = getCustomers(0); ViewData["lstCategory"] = getBlankCategory(0); dtProdMasterAll = ProductMasterData.SelectAll(); try { if (!string.IsNullOrEmpty(Convert.ToString(Session["SearchField"])) & !string.IsNullOrEmpty(Convert.ToString(Session["SearchCondition"])) & !string.IsNullOrEmpty(Convert.ToString(Session["SearchText"]))) { dtProdMasterAll = ProductMasterData.SearchfrIndex1(Convert.ToString(Session["SearchField"]), Convert.ToString(Session["SearchCondition"]), Convert.ToString(Session["SearchText"])); } } catch { } var Query = from rowProdMaster in dtProdMasterAll.AsEnumerable() select new ProductList() { ProductId = rowProdMaster.Field <Int64>("ProductId") , Model = rowProdMaster.Field <String>("Model") }; switch (sortOrder) { case "Model_asc": Query = Query.OrderBy(s => s.Model); break; default: // Name ascending Query = Query.OrderBy(s => s.Model); break; } if (command == "Export") { GridView gv = new GridView(); DataTable dt = new DataTable(); dt.Columns.Add("Product Id", typeof(Int64)); dt.Columns.Add("Model", typeof(string)); foreach (var item in Query) { dt.Rows.Add( item.ProductId , item.Model ); } gv.DataSource = dt; gv.DataBind(); ExportData(Export, gv, dt); } int pageNumber = (page ?? 1); int?pageSZ = (Convert.ToInt32(Session["PageSize"]) == 0 ? 5 : Convert.ToInt32(Session["PageSize"])); return(View(Query.ToPagedList(pageNumber, (pageSZ ?? 5)))); }