public ActionResult UpdateSupplier(SupplierModels.Supplier supplier) { GetCompanySetting(); var sCode = Entities.S_Supplier.Where(s => s.SupplierID != supplier.SupplierID && s.Code == supplier.Code).FirstOrDefault(); if (sCode != null) { var township = Entities.S_Township.ToList(); ViewBag.Township = new SelectList(township, "TownshipID", "TownshipName"); if (ViewBag.isMultiBranch == true) { var branches = Entities.S_Branch.ToList(); ViewBag.Branches = new SelectList(branches, "BranchID", "BranchName"); } ViewBag.Message = "Supplier Code Duplicated...."; ViewBag.formType = 2; return(View("SupplierEntry")); } else { if (supplier.BranchID > 0) { Entities.PrcUpdateSupplier(supplier.SupplierID, supplier.Code, supplier.SupplierName, supplier.TownshipID, supplier.Contact, supplier.Address, supplier.Phone, supplier.Email, supplier.isCredit, supplier.BranchID); } else { Entities.PrcUpdateSupplier(supplier.SupplierID, supplier.Code, supplier.SupplierName, supplier.TownshipID, supplier.Contact, supplier.Address, supplier.Phone, supplier.Email, supplier.isCredit, null); } ViewBag.Message = "Supplier Updated Successful..."; return(View("SupplierList", GetSupplier())); } }
public List <SupplierModels.Supplier> GetSupplier() { List <SupplierModels.Supplier> lstSupplier = new List <SupplierModels.Supplier>(); var supplier = Entities.PrcRetrieveSupplier(); foreach (var item in supplier) { SupplierModels.Supplier model = new SupplierModels.Supplier(); model.SupplierID = item.SupplierID; model.SupplierName = item.SupplierName; model.Code = item.Code; if (item.TownshipName == null) { model.TownshipName = "-"; } else { model.TownshipName = item.TownshipName; } if (item.BranchName == null) { model.BranchName = "-"; } else { model.BranchName = item.BranchName; } lstSupplier.Add(model); } return(lstSupplier); }
public ActionResult EditSupplier(int id) { GetCompanySetting(); var supplier = Entities.S_Supplier.Find(id); if (supplier != null) { var township = Entities.S_Township.ToList(); ViewBag.Township = new SelectList(township, "TownshipID", "TownshipName"); if (ViewBag.isMultiBranch == true) { var branches = Entities.S_Branch.ToList(); ViewBag.Branches = new SelectList(branches, "BranchID", "BranchName"); } SupplierModels.Supplier model = new SupplierModels.Supplier(); model.SupplierID = supplier.SupplierID; model.SupplierName = supplier.SupplierName; model.Code = supplier.Code; model.Phone = supplier.Phone; model.Email = supplier.Email; model.Contact = supplier.Contact; model.TownshipID = Convert.ToInt32(supplier.TownshipID); if (supplier.BranchID != null) { model.BranchID = Convert.ToInt32(supplier.BranchID); } model.Address = supplier.Address; model.isCredit = Convert.ToBoolean(supplier.IsCredit); ViewBag.formType = 2; return(View("SupplierEntry", model)); } return(View("SupplierList", GetSupplier())); }
public ActionResult InsertSupplier(SupplierModels.Supplier supplier) { var township = Entities.S_Township.ToList(); ViewBag.Township = new SelectList(township, "TownshipID", "TownshipName"); GetCompanySetting(); if (ViewBag.isMultiBranch == true) { var branches = Entities.S_Branch.ToList(); ViewBag.Branches = new SelectList(branches, "BranchID", "BranchName"); } var sCode = Entities.S_Supplier.Where(s => s.Code == supplier.Code).FirstOrDefault(); if (sCode != null) { ViewBag.Message = "Supplier Code Duplicate..."; ViewBag.Type = 2; } else { S_Supplier tbl_supplier = new S_Supplier(); tbl_supplier.SupplierName = supplier.SupplierName; tbl_supplier.Code = supplier.Code; tbl_supplier.Phone = supplier.Phone; tbl_supplier.Email = supplier.Email; tbl_supplier.Contact = supplier.Contact; tbl_supplier.Address = supplier.Address; if (supplier.BranchID != 0) { tbl_supplier.BranchID = supplier.BranchID; } else { tbl_supplier.BranchID = null; } tbl_supplier.TownshipID = supplier.TownshipID; tbl_supplier.IsCredit = supplier.isCredit; tbl_supplier.IsDefault = false; Entities.S_Supplier.Add(tbl_supplier); Entities.SaveChanges(); ModelState.Clear(); ViewBag.Message = "New Supplier is inserted successful.."; ViewBag.Type = 1; } return(View("SupplierEntry")); }
public List <SupplierModels.Supplier> SearchingSupplierData(string supplier, int township, int branch) { List <SupplierModels.Supplier> lstSupplier = new List <SupplierModels.Supplier>(); var data = Entities.PrcSearchSupplierData(supplier, township, branch); foreach (var item in data) { SupplierModels.Supplier model = new SupplierModels.Supplier(); model.SupplierID = item.SupplierID; model.SupplierName = item.SupplierName; model.Code = item.Code; model.TownshipName = item.TownshipName; model.BranchName = item.BranchName; lstSupplier.Add(model); } return(lstSupplier); }