public ActionResult AddNewCustomer(int?id) { int customerTypeIdx; objCustomerProperty = new Customers_Property(); objCustomerProperty.idx = Convert.ToInt32(id); objCustomer = new Customers_BLL(objCustomerProperty); DataTable customerTypes = objCustomer.GetCustomerType(); List <CustomerType_Property> CustomersLST = new List <CustomerType_Property>(); foreach (DataRow dr in customerTypes.Rows) { CustomerType_Property objVendorsCat = new CustomerType_Property(); objVendorsCat.customerType = dr["customerType"].ToString(); objVendorsCat.idx = Convert.ToInt32(dr["idx"].ToString()); CustomersLST.Add(objVendorsCat); } ViewBag.CustomersLST = CustomersLST; if (id != null || id > 0) { var dt = objCustomer.GetCustomerById(); objCustomerProperty.idx = int.Parse(dt.Rows[0]["idx"].ToString()); int.TryParse(dt.Rows[0]["customerTypeIdx"].ToString(), out customerTypeIdx); objCustomerProperty.customerTypeIdx = customerTypeIdx; //objCustomerProperty.vendorCatIdx = int.Parse(dt.Rows[0]["vendorCatIdx"].ToString()); //objVendorsProperty.unitIdx = int.Parse(dt.Rows[0]["unitIdx"].ToString()); objCustomerProperty.contact = (dt.Rows[0]["contact"].ToString()); objCustomerProperty.customerCode = (dt.Rows[0]["customerCode"].ToString()); objCustomerProperty.customerName = (dt.Rows[0]["customerName"].ToString()); objCustomerProperty.address = (dt.Rows[0]["address"].ToString()); } return(View(objCustomerProperty)); }
public DataTable GetCustomerByID(int id) { if (Session["LOGGEDIN"] != null) { try { Customers_Property ObjCustomer_Property = new Customers_Property(); ObjCustomer_Property.idx = id; Customers_BLL objvendorbll = new Customers_BLL(ObjCustomer_Property); return(objvendorbll.GetCustomerById()); } catch (Exception ex) { return(new DataTable()); } } else { return(new DataTable()); } }
public ActionResult AddNewCustomer(int?id) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); string pagename = @"/" + controllerName + @"/" + actionName; var page = (List <LP_Pages_Property>)Session["PageList"]; if (Session["LoggedIn"] != null && Helper.CheckPageAccess(pagename, page) && Session["ISADMIN"] != null && Convert.ToBoolean(Session["ISADMIN"].ToString()) == true) { int customerTypeIdx; objCustomerProperty = new Customers_Property(); objCustomerProperty.idx = Convert.ToInt32(id); objCustomer = new Customers_BLL(objCustomerProperty); DataTable customerTypes = objCustomer.GetCustomerType(); List <CustomerType_Property> CustomersLST = new List <CustomerType_Property>(); foreach (DataRow dr in customerTypes.Rows) { CustomerType_Property objVendorsCat = new CustomerType_Property(); objVendorsCat.customerType = dr["customerType"].ToString(); objVendorsCat.idx = Convert.ToInt32(dr["idx"].ToString()); CustomersLST.Add(objVendorsCat); } ViewBag.CustomersLST = CustomersLST; if (id != null || id > 0) { var dt = objCustomer.GetCustomerById(); objCustomerProperty.idx = int.Parse(dt.Rows[0]["idx"].ToString()); int.TryParse(dt.Rows[0]["customerTypeIdx"].ToString(), out customerTypeIdx); objCustomerProperty.customerTypeIdx = customerTypeIdx; //objCustomerProperty.vendorCatIdx = int.Parse(dt.Rows[0]["vendorCatIdx"].ToString()); //objVendorsProperty.unitIdx = int.Parse(dt.Rows[0]["unitIdx"].ToString()); objCustomerProperty.contact = (dt.Rows[0]["contact"].ToString()); objCustomerProperty.customerCode = (dt.Rows[0]["customerCode"].ToString()); objCustomerProperty.customerName = (dt.Rows[0]["customerName"].ToString()); objCustomerProperty.address = (dt.Rows[0]["address"].ToString()); return(View(objCustomerProperty)); } else { objCustomerProperty.createdByUserIdx = Convert.ToInt16(Session["UID"].ToString()); objCustomer = new Customers_BLL(); LP_GenerateTransNumber_Property objtrans = new LP_GenerateTransNumber_Property(); objtrans.TableName = "customers"; objtrans.Identityfieldname = "idx"; objtrans.userid = Session["UID"].ToString(); objCustomerProperty.customerCode = objCustomer.GenerateSO(objtrans); return(View(objCustomerProperty)); } } else { if (Session["LoggedIn"] == null) { return(RedirectToAction("Login", "Account")); } else { return(RedirectToAction("NotAuthorized", "Account")); } } }