public bool AddUser(tblRegister reg) { bool result = false; if (reg.FirstName.Trim().Length == 0) { result = false; } else if (reg.LastName.Trim().Length == 0) { result = false; } else if (reg.Email.Length < 0) { result = false; } else if (!reg.MobileNumber.HasValue) { result = false; } else { result = true; } return(result); }
public ActionResult DeleteConfirmed(int id) { tblRegister tblRegister = db.tblRegisters.Find(id); db.tblRegisters.Remove(tblRegister); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "UserID,FirstName,LastName,DOB,Gender,Contact,Email,Password,Category")] tblRegister tblRegister) { if (ModelState.IsValid) { db.Entry(tblRegister).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblRegister)); }
private void btnRegister_Click(object sender, RoutedEventArgs e) { var objvalidate = new validation(); var objReg = new Method(); var objRegister = new tblRegister(); String IDnum, cell, name, surname, homeAddress, email, password, repassword, gender; string msg = ""; // string n = "/n"; int age; IDnum = txtID.Text; name = txtName.Text; homeAddress = txtHomeAddress.Text; email = txtEmail.Text; password = txtPassword.Password; repassword = txtRe_password.Password; surname = txtSurname.Text; cell = txtCellnumber.Text; try { if (IDnum == "" && name == "" && password == "" && surname == "" && cell == "" && email == "") { messageBox("all field must be fill with yuor correct details"); } msg += objvalidate.IDValidation(IDnum); msg += objvalidate.validatePassword(password, repassword); if (objReg.getRegisterUser(IDnum) == null) { gender = objvalidate.getGender(IDnum); age = objvalidate.getAge(IDnum); objReg.setRegister(IDnum, name, surname, email, cell, gender, age, password); messageBox("Thanks you for registering for Emergency Medical Servise"); this.Frame.Navigate(typeof(MainPage)); } else { messageBox("user already registerd in the system"); } } catch (Exception ex) { messageBox(ex.Message); } }
public ActionResult Create([Bind(Include = "UserID,FirstName,LastName,DOB,Gender,Contact,Email,Password,Category")] tblRegister tblRegister) { if (ModelState.IsValid) { db.tblRegisters.Add(tblRegister); db.SaveChanges(); return(RedirectToAction("Login", "Main")); } return(View(tblRegister)); }
public ActionResult Register(tblRegister d) { try { if (d.FirstName != null) { bool result = acc.AddUser(d); if (result) { Account ac = new Account(); ac.Register(d); TempData["registered"] = "success"; ViewBag.Success = "Register Successfully.....Please Log In"; return(RedirectToAction("SignIn")); } else { TempData["registered"] = "error"; ViewBag.Error = "Something Went wrong....."; return(View()); } //if (i > 0) //{ // TempData["registered"] = "success"; // ViewBag.Success = "Register Successfully.....Please Log In"; // if (Session["user"] != null) // { // return RedirectToAction("Register"); // } // else // { // return RedirectToAction("SignIn"); // } //} //else //{ // TempData["registered"] = "error"; // ViewBag.Error = "Something Went wrong....."; // return View(); //} } return(View()); } catch (Exception ex) { TempData["registered"] = "duplicate"; ViewBag.Error = "Something Went wrong....."; return(View()); } }
// GET: tblRegisters/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblRegister tblRegister = db.tblRegisters.Find(id); if (tblRegister == null) { return(HttpNotFound()); } return(View(tblRegister)); }
public int Register(tblRegister register) { int i = 0; try { i = db.spRegister(register.RoleID, register.FirstName, register.LastName, register.Email, register.tblUser.Password, register.Gender, Convert.ToInt32(register.MobileNumber), register.BirthDate, register.Availability, register.Specialization, register.Age, register.IsActive, false); return(i); } catch (Exception ex) { throw ex; } }
public ActionResult Command(FormCollection collection, tblRegister registry) { string Name = collection["txtName"]; string Hotline = collection["txtHotline"]; string selectcate = collection["selectcate"]; registry.Name = Name; registry.Mobile = Hotline; registry.idCate = int.Parse(selectcate); db.tblRegisters.Add(registry); db.SaveChanges(); Session["registry"] = "<script>$(document).ready(function(){ alert('Bạn đã đăng ký thành công') });</script>"; return(Redirect("/Default/Index")); }
public void Register() { tblRegister obj = new tblRegister(); obj.RoleID = 1; obj.FirstName = "Vikash"; obj.LastName = "kumar"; obj.Gender = "Male"; obj.Email = "*****@*****.**"; obj.MobileNumber = 11; obj.BirthDate = Convert.ToDateTime("10/10/2017"); // Arrange AccountController controller = new AccountController(); ActionResult result = controller.Register(obj); // Act // Assert Assert.IsNotNull(result); }
public ActionResult Command(FormCollection collection) { tblRegister register = new tblRegister(); register.Name = collection["txtName"]; register.Mobile = collection["txtMobile"]; register.Address = collection["txtAddress"]; register.Email = collection["txtEmail"]; if (collection["txtDatemua"] != null) { register.DateTimebyy = DateTime.Parse(collection["txtDatemua"]); } else { register.DateTimebyy = DateTime.Now; } if (collection["txtDatethay"] != null) { register.DateTime = DateTime.Parse(collection["txtDatethay"]); } else { register.DateTime = DateTime.Now; } db.tblRegisters.Add(register); db.SaveChanges(); foreach (string key in Request.Form) { var checkbox = ""; if (key.StartsWith("chk_")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { Int32 idll = Convert.ToInt32(key.Remove(0, 4)); int idkh = int.Parse(db.tblRegisters.OrderByDescending(p => p.id).ToList()[0].id.ToString()); tblConnectLoiloc clloiloc = new tblConnectLoiloc(); clloiloc.idkh = idkh; clloiloc.idll = idll; db.tblConnectLoilocs.Add(clloiloc); db.SaveChanges(); } } } TblConfig config = db.TblConfigs.First(); var fromAddress = config.UserEmail; var toAddress = config.Email; var MaxRigister = db.tblRegisters.OrderByDescending(p => p.id).Take(1).ToList(); string fromPassword = config.PassEmail; string ararurl = Request.Url.ToString(); var listurl = ararurl.Split('/'); string urlhomes = ""; for (int i = 0; i < listurl.Length - 2; i++) { if (i > 0) { urlhomes += "/" + listurl[i]; } else { urlhomes += listurl[i]; } } int Makh = int.Parse(MaxRigister[0].id.ToString()); string subject = "Đăng ký thay lõi lọc nước thành công"; string chuoihtml = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /><title>Thông tin đơn hàng</title></head><body style=\"background:#f2f2f2; font-family:Arial, Helvetica, sans-serif\"><div style=\"width:750px; height:auto; margin:5px auto; background:#FFF; border-radius:5px; overflow:hidden\">"; chuoihtml += "<div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\"><span style=\"font-size:14px; line-height:40px; color:#FFF; margin:auto 20px; float:left\">" + DateTime.Now.Date + "</span><span style=\"font-size:14px; line-height:40px; float:right; margin:auto 20px; color:#FFF; text-transform:uppercase\">Hotline : " + config.HotlineIN + "</span></div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\"><div style=\"width:35%; height:100%; margin:0px; float:left\"><a href=\"/\" title=\"\"><img src=\"" + urlhomes + "" + config.Logo + "\" alt=\"Logo\" style=\"margin:8px; display:block; max-height:95% \" /></a></div><div style=\"width:60%; height:100%; float:right; margin:0px; text-align:right\"><span style=\"font-size:18px; margin:20px 5px 5px 5px; display:block; color:#ff5a00; text-transform:uppercase\">" + config.Name + "</span><span style=\"display:block; margin:5px; color:#515151; font-size:13px; text-transform:uppercase\">Lớn nhất - Chính hãng - Giá rẻ nhất việt nam</span> </div> </div>"; chuoihtml += "<span style=\"text-align:center; margin:10px auto; font-size:20px; color:#000; font-weight:bold; text-transform:uppercase; display:block\">Thông tin dăng ký</span>"; chuoihtml += " <div style=\"width:90%; height:auto; margin:10px auto; background:#f2f2f2; padding:15px\">"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Website đăng ký : <span style=\"color:#1c7fc4\">" + urlhomes + "</span></p>"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Ngày đăng ký : <span style=\"color:#1c7fc4\">Vào lúc " + DateTime.Now.Hour + " giờ " + DateTime.Now.Minute + " phút ( ngày " + DateTime.Now.Day + " tháng " + DateTime.Now.Month + " năm " + DateTime.Now.Year + ") </span></p>"; chuoihtml += "<p style=\"font-size:14px; color:#464646; margin:5px 20px\">Mã khách hàng : <span style=\"color:#1c7fc4\">" + Makh + " </span></p>"; chuoihtml += "<div style=\" width:100%; margin:15px 0px\">"; chuoihtml += "<div style=\"width:90%; height:auto; float:left; margin:0px; border:1px solid #d5d5d5\">"; chuoihtml += "<div style=\" width:100%; height:30px; float:left; background:#1c7fc4; font-size:12px; color:#FFF; text-indent:15px; line-height:30px\"> Thông tin đăng ký </div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left\">"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Họ và tên :<span style=\"font-weight:bold\"> " + collection["txtName"] + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Địa chỉ :<span style=\"font-weight:bold\"> " + collection["txtAddress"] + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Điện thoại :<span style=\"font-weight:bold\"> " + collection["txtMobile"] + "</span></p>"; chuoihtml += "<p style=\"font-size:12px; margin:5px 10px\">Email :<span style=\"font-weight:bold\">" + collection["txtEmail"] + "</span></p>"; chuoihtml += "</div>"; chuoihtml += "</div>"; chuoihtml += "</div>"; chuoihtml += "<div style=\"width:100%; height:auto; float:left; margin:0px\">"; chuoihtml += "<hr style=\"width:80%; height:1px; background:#d8d8d8; margin:20px auto 10px auto\" />"; chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">" + config.Address + "</p>"; chuoihtml += "<p style=\"font-size:12px; text-align:center; margin:5px 5px\">Điện thoại : " + config.MobileIN + " - " + config.HotlineIN + "</p>"; chuoihtml += " <p style=\"font-size:12px; text-align:center; margin:5px 5px; color:#ff7800\">Thời gian mở cửa : Từ 7h30 đến 18h30 hàng ngày (làm cả thứ 7, chủ nhật). Hãy liên hệ để được giảm giá.</p>"; chuoihtml += "</div>"; chuoihtml += "<div style=\"clear:both\"></div>"; chuoihtml += " </div>"; chuoihtml += " <div style=\"width:100%; height:40px; float:left; margin:0px; background:#1c7fc4\">"; chuoihtml += "<span style=\"font-size:12px; text-align:center; color:#FFF; line-height:40px; display:block\">Copyright (c) 2002 – 2015 VINCOM VIET NAM. All Rights Reserved</span>"; chuoihtml += " </div>"; chuoihtml += "</div>"; chuoihtml += "</body>"; chuoihtml += "</html>"; string body = chuoihtml; var smtp = new System.Net.Mail.SmtpClient(); { smtp.Host = config.Host; smtp.Port = int.Parse(config.Port.ToString()); smtp.EnableSsl = true; smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; smtp.Credentials = new NetworkCredential(fromAddress, fromPassword); smtp.Timeout = int.Parse(config.Timeout.ToString()); } using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body, IsBodyHtml = true, }) { smtp.Send(message); } string emails = collection["txtEmail"]; using (var messages = new MailMessage(fromAddress, emails) { Subject = subject, Body = body, IsBodyHtml = true, }) { smtp.Send(messages); } Session["Register"] = "<script>$(document).ready(function(){ alert('Bạn đã đăng ký thành công !') });</script>"; return(Redirect("/")); }