public List <DisplayCustomers> GetAllUser(string Name, string MobileNo) { Dictionary <string, MySqlParameter> Parameter = new Dictionary <string, MySqlParameter>(); Parameter["Nam"] = new MySqlParameter("Nam", Name); Parameter["Mob"] = new MySqlParameter("Mob", MobileNo); DataTable dt = _GenClassnew.ExecuteQuery("SP_CustomerDetails", Parameter); List <DisplayCustomers> UserList = new List <DisplayCustomers>(); foreach (DataRow row in dt.Rows) { DisplayCustomers UM = new DisplayCustomers(); UM.CustomerID = row.Field <int>("CustomerID"); UM.Name = row.Field <string>("Name"); UM.Mobile = row.Field <string>("Mobile"); UM.Email = row.Field <string>("Email"); UM.MembershipName = row.Field <string>("Memmership"); UM.BatchName = row.Field <string>("BatchName"); UM.Payment = row.Field <int>("Payment"); UM.Outstanding = row.Field <int>("Outstanding"); UM.TotalPayment = (UM.Payment + UM.Outstanding).ToString(); UM.DateOfPayment = row.Field <DateTime>("DateOfPayment"); UM.ExpiryDate = row.Field <DateTime>("ExpiryDate"); UserList.Add(UM); } return(UserList); }
// GET: Customer public ActionResult Index(int?p, string filter) { DisplayCustomers customer = new DisplayCustomers(); if (p == null) { p = 1; } if (Session["UserId"] == null) { return(RedirectToAction("Index", "Login")); } else { try { //Ürünleri alıyoruz using (var db = new KTOtomasyonEntities()) { //Filter IQueryable <vCustomers> query = null; if (string.IsNullOrEmpty(filter)) { query = db.vCustomers.Where(x => 1 == 1); } else { query = db.vCustomers.Where(x => x.CustomerName.Contains(filter) && (x.PhoneNumber.Contains(filter))); } customer.CustomerList = query.OrderByDescending(x => x.PhoneNumber).Skip(defaultPageSize * (p.Value - 1)).Take(defaultPageSize).ToList(); customer.CurrentPage = p.Value; customer.TotalCount = query.Count(); if ((customer.TotalCount % defaultPageSize) == 0) { customer.TotalPage = customer.TotalCount / defaultPageSize; } else { customer.TotalPage = (customer.TotalCount / defaultPageSize) + 1; } } } catch (Exception) { RedirectToAction("ErrorPage", "Home"); } return(View(customer)); } }
public List <DisplayCustomers> GetCustomerHistory(int custID) { List <DisplayCustomers> CustList = new List <DisplayCustomers>(); Dictionary <string, MySqlParameter> Parameter = new Dictionary <string, MySqlParameter>(); Parameter["CustID"] = new MySqlParameter("CustID", custID); DataTable dt = _GenClassnew.ExecuteQuery("SP_CustomerHistory", Parameter); foreach (DataRow row in dt.Rows) { DisplayCustomers history = new DisplayCustomers(); history.Name = row.Field <string>("Name"); history.MembershipName = row.Field <string>("Memmership"); history.BatchName = row.Field <string>("BatchName"); history.date = row.Field <DateTime>("DateOfPayment").ToString("dd/MM/yyyy"); CustList.Add(history); } return(CustList); }