public int Login_check(string name, string Password) { tb_Customer customer = new tb_Customer(); customer = _Service.LoadEntities(x => x.Username == name && x.Password == Password).FirstOrDefault(); if (customer != null) { return(customer.ID); } else { return(-1); } }
protected void btnCreateCustomer(object sender, EventArgs e) { try { tb_Customer info = new tb_Customer(); string customerGrouptemp = Request.Form["ipcustomerGroupSelection"]; int customerGroup = 0; if (customerGrouptemp != null) { customerGroup = int.Parse(customerGrouptemp); } string customerCode = Request.Form["ctl00$ContentPlaceHolder1$ipcustomerCode"]; string customerLastname = Request.Form["ctl00$ContentPlaceHolder1$ipcustomerLastname"]; string customerFirstname = Request.Form["ctl00$ContentPlaceHolder1$ipcustomerFirstname"]; string customerEmail = Request.Form["ctl00$ContentPlaceHolder1$ipcustomerEmail"]; string customerUsername = Request.Form["ctl00$ContentPlaceHolder1$ipcustomerUsername"]; string customerPass = Request.Form["ctl00$ContentPlaceHolder1$ipcustomerPassword"]; string customerPhoneNumber = Request.Form["ctl00$ContentPlaceHolder1$ipcustomerPhoneNumber"]; string customerAddress = Request.Form["ctl00$ContentPlaceHolder1$ipcustomerAddress"]; string customerDesc = Request.Form["ctl00$ContentPlaceHolder1$ipcustomerDesc"]; string customerAvatar = Path.GetFileName(ipcustomerAvatarFile.FileName); string path = Server.MapPath("~/image_customer/"); ipcustomerAvatarFile.SaveAs(path + customerAvatar); info.Avatar = "../image_customer/" + customerAvatar; info.CustomerNo = customerCode; info.FirstName = customerFirstname; info.LastName = customerLastname; info.UserName = customerUsername; info.Password = customerPass; info.Phone = customerPhoneNumber; info.Address = customerAddress; info.Email = customerEmail; info.Description = customerDesc; info.CustomerGroup = customerGroup; info.CreateDate = DateTime.Now; db.tb_Customer.Add(info); db.SaveChanges(); Response.Write("<script>alert('tạo khách hàng mới thành công !')</script>"); getCustomerList(); } catch (Exception) { Response.Write("<script>alert('Khởi tạo không thành công, vui lòng thử lại !')</script>"); } }
protected void btnDeleteCustomer(object sender, EventArgs e) { try { int CusID = 0; string cID = Request.Form["ctl00$ContentPlaceHolder1$CusID"]; if (cID != null) { CusID = int.Parse(cID); tb_Customer t = (tb_Customer)db.tb_Customer.Where(b => b.CustomerID == CusID).First(); db.tb_Customer.Remove(t); db.SaveChanges(); Response.Write("<script>alert('Xoa khách hàng thành công !')</script>"); getCustomerList(); } } catch (Exception) { Response.Write("<script>alert('Xóa không thành công, vui lòng thử lại !')</script>"); } }
public int AddCustomer(tb_Customer model) { tb_Customer newmodel = _Service.AddEntity(model); return(newmodel.ID); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string action = Request.QueryString["action"].ToString(); switch (action) { #region getCategoryList case "getCategoryList": { string html = Generate.getCategoryList(); Response.Write(html); } break; #endregion ; #region LoginNow case "LoginNow": { string customerLoginHTML = ""; string cusEmail = Request.QueryString["cusEmail"].ToString(); string cusPass = Request.QueryString["cusPass"].ToString(); var customerInfo = db.tb_Customer.Where(t => t.Email == cusEmail).FirstOrDefault(); var tblEmail = customerInfo.Email; var tblPass = customerInfo.Password; // if (cusEmail.Equals(customerInfo.Email)) if (cusEmail == tblEmail) { //if (cusPass.Equals(customerInfo.Password)) if (cusPass == tblPass) { //long cusId = customerInfo.CustomerID; // Session["cusID"] = cusId; //login success Session["cusName"] = customerInfo.FirstName; //Response.Write("1"); customerLoginHTML = "1"; } else { //password wrong //Response.Write("2"); customerLoginHTML = "2"; } } else { //email not existing //Response.Write("3"); customerLoginHTML = "error"; } Response.Write(customerLoginHTML); } break; #endregion #region Registernew case "Registernew": { String customerRegisterHTML = ""; try { string regFirstName = Request.QueryString["regFirstName"].ToString(); string regLastName = Request.QueryString["regLastName"].ToString(); string regEmail = Request.QueryString["regEmail"].ToString(); string regPassword = Request.QueryString["regPassword"].ToString(); //insert to database tb_Customer thlCustomer = new tb_Customer(); thlCustomer.FirstName = regFirstName; thlCustomer.LastName = regLastName; thlCustomer.Email = regEmail; thlCustomer.Password = regPassword; thlCustomer.CustomerGroup = 3; thlCustomer.CustomerNo = "cusfront2018"; thlCustomer.CreateDate = DateTime.Now; db.tb_Customer.Add(thlCustomer); db.SaveChanges(); Response.Write("<script>alert('tạo khách hàng mới thành công !')</script>"); } catch (Exception) { customerRegisterHTML = "error"; } Response.Write(customerRegisterHTML); } break; #endregion #region [Xu ly from contact] case "ContactInsert": ContactInsert(); break; #endregion } } }