public static KhachHangDTO GetAccountByID(string id) { KhachHangDTO cs = new KhachHangDTO(); string query = "select * from db3c04c35a9c6b45918ba3a551005e16ee.account where ID like '" + id + "'"; DataTable dt = DataProvider.ExecuteQuery(query); for (int i = 0; i < dt.Rows.Count; i++) { cs.ID = (string)dt.Rows[i]["ID"]; cs.UserName = (string)dt.Rows[i]["UserName"]; cs.Password = (string)dt.Rows[i]["Password"]; cs.BirthDay = (string)dt.Rows[i]["BirthDay"]; cs.Sex = (string)dt.Rows[i]["Sex"]; cs.Email = (string)dt.Rows[i]["Email"]; cs.Phone = (string)dt.Rows[i]["Phone"]; cs.Address = (string)dt.Rows[i]["Address"]; cs.Type = (string)dt.Rows[i]["Type"]; cs.Status = (string)dt.Rows[i]["Status"]; } return cs; }
public static List<KhachHangDTO> GetAllCustomer() { List<KhachHangDTO> rs = new List<KhachHangDTO>(); string query = "select * from db3c04c35a9c6b45918ba3a551005e16ee.account"; DataTable dt = DataProvider.ExecuteQuery(query); for (int i = 0; i < dt.Rows.Count; i++) { KhachHangDTO cs = new KhachHangDTO(); cs.ID = (string)dt.Rows[i]["ID"]; cs.UserName = (string)dt.Rows[i]["UserName"]; cs.Password = (string)dt.Rows[i]["Password"]; cs.BirthDay = (string)dt.Rows[i]["BirthDay"]; cs.Sex = (string)dt.Rows[i]["Sex"]; cs.Email = (string)dt.Rows[i]["Email"]; cs.Phone = (string)dt.Rows[i]["Phone"]; cs.Address = (string)dt.Rows[i]["Address"]; cs.Type = (string)dt.Rows[i]["Type"]; cs.Status = (string)dt.Rows[i]["Status"]; if (cs.Type == "customer") { rs.Add(cs); } } return rs; }
public ActionResult DangKi() { ViewBag.userID = ""; if (Request["newUserName"] != null) { KhachHangDTO dto = new KhachHangDTO(); dto.UserName = Request["newUserName"]; dto.Password = Request["password"]; dto.Email = Request["email"]; dto.Phone = Request["password"]; dto.Address = Request["address"]; dto.BirthDay = "12/12/2012"; dto.Sex = "Male"; dto.Type = "customer"; dto.Status = "normal"; string userID = KhachHangDAO.Register(dto); if (userID != "") { ViewBag.userID = userID; //send cookie // var userCookie = new HttpCookie("userID", userID); userCookie.Expires.AddHours(1); HttpContext.Response.Cookies.Add(userCookie); return Redirect("../home/index"); } } return View(); }
public static string Register(KhachHangDTO dto) { string id = NextAccountID(); string query = "insert into db3c04c35a9c6b45918ba3a551005e16ee.account " + "value ('" + id + "','" + dto.UserName + "','" + dto.Password + "','" + dto.BirthDay + "','" + dto.Sex + "','" + dto.Email + "','" + dto.Phone + "','" + dto.Address + "','" + dto.Type + "','" + dto.Status +"')"; if (DataProvider.ExecuteNonQuery(query)) { return id; } else { return ""; } }