//here is forget password uwer exist or not it valid user check with email public Companydetail forgetpassword(Companydetail Reg) { string connection = ConfigurationManager.ConnectionStrings["temp_transport"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); using (SqlCommand cm = new SqlCommand("forgetpassword", con)) { cm.CommandType = System.Data.CommandType.StoredProcedure; cm.Parameters.AddWithValue("@User_Email", Reg.UserEmail); SqlDataReader dr = cm.ExecuteReader(); if (dr.Read()) { Reg.UserFirstName = dr["User_FirstName"].ToString(); Reg.UserLastName = dr["User_LastName"].ToString(); Reg.User_PhoneNumber = dr["User_PhoneNumber"].ToString(); } //else //{ //} } return(Reg); } }
{ //here is user verified user valid or not public string register(Companydetail Reg) { string message = ""; string connection = ConfigurationManager.ConnectionStrings["temp_transport"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); using (SqlCommand cm = new SqlCommand("validuser", con)) { cm.CommandType = System.Data.CommandType.StoredProcedure; cm.Parameters.AddWithValue("@User_PhoneNumber", Reg.User_PhoneNumber); cm.Parameters.AddWithValue("@User_Email", Reg.UserEmail); SqlDataReader dr = cm.ExecuteReader(); if (dr.Read()) { //Reg.error = "Sorry this user is already exist"; message = "0"; } else { message = "1"; // con.Close(); } } return(message); } }
//send mail method are call in customer,driver,admin public ActionResult sendmail() { string numbers = "0123456789"; Random objrandom = new Random(); string strrandom = string.Empty; for (int i = 0; i < 5; i++) { int temp = objrandom.Next(0, numbers.Length); strrandom += temp; } ViewBag.otp = strrandom; TempData["code"] = strrandom; TempData.Keep(); Companydetail verifiedUser = TempData["Userdata"] as Companydetail; //string ahsan = verifiedUser.UserFirstName; WebMail.Send(verifiedUser.UserEmail, "Well Come '" + verifiedUser.UserFirstName + "_" + verifiedUser.UserLastName + "' Sindhu Online Transport Company", "Dear Sir,<br/> You are Register this mobile NO :" + verifiedUser.User_PhoneNumber + "<br/><br/> Your are Register With Email :" + verifiedUser.UserEmail + "<br/><br/>Your Verfy Code Is :" + strrandom , null, null, null, true, null, null, null, null, null, null); TempData.Keep(); return(RedirectToAction("VerfyCode", "Registration")); }
public ActionResult ForgetPassword(Companydetail Reg, string command) { if (ModelState.IsValidField("UserEmail")) { CustomerRegister cust_reg = new CustomerRegister(); if (command == "Reset Password") { TempData["UserData"] = cust_reg.forgetpassword(Reg); Companydetail CheckedUser = TempData["Userdata"] as Companydetail; string phone = CheckedUser.User_PhoneNumber; TempData["Phone"] = phone; if (phone == null) //dont get valu data base show error message { TempData["Error"] = "User is Not exist Plz Try Again"; return(RedirectToAction("ForgetPassword", "Registration")); } else //if user is valid then send code and redirect in verify code { TempData["RegistrationRole"] = command; TempData.Keep(); sendmail(); return(RedirectToAction("VerfyCode", "Registration", new { id = Session["LoginId"] })); } } } return(View()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email_Id,Address,Mobile_Number,Website")] Companydetail companydetail) { if (id != companydetail.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(companydetail); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CompanydetailExists(companydetail.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(companydetail)); }
public async Task <IActionResult> Create([Bind("Id,Name,Email_Id,Address,Mobile_Number,Website")] Companydetail companydetail) { if (ModelState.IsValid) { _context.Add(companydetail); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(companydetail)); }
//here after verify Driver save in database also forgin key store public string Driver_Register(Companydetail verifiedUser) { string user_id = ""; string connection = ConfigurationManager.ConnectionStrings["temp_transport"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); using (SqlCommand cmd = new SqlCommand("Admin_Registration", con)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@User_FirstName", verifiedUser.UserFirstName); cmd.Parameters.AddWithValue("@User_LastName", verifiedUser.UserLastName); cmd.Parameters.AddWithValue("@User_PhoneNumber", verifiedUser.User_PhoneNumber); cmd.Parameters.AddWithValue("@User_Address", verifiedUser.UserAddress); cmd.Parameters.AddWithValue("@User_Cnic", verifiedUser.UserCnic); cmd.Parameters.AddWithValue("@User_Email", verifiedUser.UserEmail); cmd.Parameters.AddWithValue("@User_Password", verifiedUser.User_Password); cmd.Parameters.AddWithValue("@User_Role_Id", 2); cmd.Parameters.AddWithValue("@User_Image", verifiedUser.Image); cmd.Parameters.AddWithValue("@CompanyName", verifiedUser.user_comp); cmd.Parameters.AddWithValue("@CompanyType", verifiedUser.user_comp_type); cmd.Parameters.AddWithValue("@UserCity", verifiedUser.user_City); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { user_id = Convert.ToInt32(dr["UserId"]).ToString(); } //company detail con.Close(); con.Open(); using (SqlCommand cm = new SqlCommand("Driver_info", con)) { //cm.CommandType = System.Data.CommandType.StoredProcedure; //cm.Parameters.AddWithValue("@DriverSalary", verifiedUser.Driver_Salery); //cm.Parameters.AddWithValue("@DriverExperience", verifiedUser.Dreiver_exprience); //cm.Parameters.AddWithValue("@DriverType", verifiedUser.Driver_Type); //cm.Parameters.AddWithValue("@DriverPosition", verifiedUser.Driver_position); //cm.Parameters.AddWithValue("@DriverRouteCharge", verifiedUser.Driver_Routchaege); cm.Parameters.AddWithValue("@DriverUserId", user_id); cm.ExecuteNonQuery(); con.Close(); return(user_id); } } } }
public ActionResult UpdatePassword(Companydetail Reg, string user_ph) { user_ph = (TempData["Phone"].ToString()); CustomerRegister cust_reg = new CustomerRegister(); string check = cust_reg.UpdatePassword(Reg, user_ph); if (check == "1") { TempData["updatemessage"] = "Password Updated Successfully"; } else { TempData["updatemessage"] = "Problem"; } return(RedirectToAction("Login", "Registration", new { id = Session["LoginId"] })); }
public List <Companydetail> userlogin(Companydetail log, int f_key) { //encrypted password string enc = log.User_Password; byte[] encode = new byte[enc.Length]; encode = Encoding.UTF8.GetBytes(log.User_Password); string enc_password = Convert.ToBase64String(encode); List <Companydetail> reglist = new List <Companydetail>(); string connection = ConfigurationManager.ConnectionStrings["temp_transport"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); using (SqlCommand cm = new SqlCommand("Login", con)) { cm.CommandType = System.Data.CommandType.StoredProcedure; cm.Parameters.AddWithValue("@User_PhoneNumber", log.User_PhoneNumber); cm.Parameters.AddWithValue("@User_Password", enc_password); cm.Parameters.AddWithValue("@f_key", f_key); SqlDataReader dr = cm.ExecuteReader(); if (dr.Read()) { log.UserFirstName = dr["User_FirstName"].ToString(); log.UserLastName = dr["User_LastName"].ToString(); log.UserId = int.Parse(dr["UserId"].ToString()); log.Image = dr["User_Image"].ToString(); log.user_comp = dr["CompanyName"].ToString(); } //else //{ //} } reglist.Add(log); return(reglist); } }
//here after verify customer save in database also forgin key store public string Customer_register(Companydetail verifiedUser) { //encrypted password string enc = verifiedUser.User_Password; byte[] encode = new byte[enc.Length]; encode = Encoding.UTF8.GetBytes(verifiedUser.User_Password); string enc_password = Convert.ToBase64String(encode); string message = ""; string connection = ConfigurationManager.ConnectionStrings["temp_transport"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); using (SqlCommand cmd = new SqlCommand("User_Registration", con)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@User_FirstName", verifiedUser.UserFirstName); cmd.Parameters.AddWithValue("@User_LastName", verifiedUser.UserLastName); cmd.Parameters.AddWithValue("@User_PhoneNumber", verifiedUser.User_PhoneNumber); cmd.Parameters.AddWithValue("@User_Address", verifiedUser.UserAddress); cmd.Parameters.AddWithValue("@User_Cnic", verifiedUser.UserCnic); cmd.Parameters.AddWithValue("@User_Email", verifiedUser.UserEmail); cmd.Parameters.AddWithValue("@User_Password", enc_password); cmd.Parameters.AddWithValue("@User_Role_Id", 4); cmd.Parameters.AddWithValue("@User_Image", verifiedUser.Image); cmd.Parameters.AddWithValue("@CompanyName", verifiedUser.user_comp); cmd.Parameters.AddWithValue("@CompanyType", verifiedUser.user_comp_type); cmd.Parameters.AddWithValue("@UserCity", verifiedUser.user_City); cmd.ExecuteNonQuery(); con.Close(); message = "User sucessfully add"; return(message); } } }
public ActionResult AdminRegister(Companydetail Reg, string command) { if (command == "Register") { ModelState["PinCode"].Errors.Clear(); ModelState["VehicleNumber"].Errors.Clear(); if (ModelState.IsValid) { CustomerRegister Admin = new CustomerRegister(); string userexist = Admin.register(Reg); if (userexist == "0") { TempData["Erroruserexist"] = "User is already exist ,Plz login"; return(RedirectToAction("AdminRegister", "Registration")); } else { PictureSave(Reg); if (TempData["extensionerror"] == null) { TempData["RegistrationRole"] = command; TempData.Keep(); sendmail(); return(RedirectToAction("VerfyCode", "Registration")); } else { return(RedirectToAction("AdminRegister", "Registration")); } } } } return(View()); }
// GET: Registration //here is picture method called in customer,admin and driver public Models.Companydetail PictureSave(Companydetail Reg) { if (Reg.image_file.FileName != "") { string filename = Path.GetFileNameWithoutExtension(Reg.image_file.FileName); string extension = Path.GetExtension(Reg.image_file.FileName).ToLower(); if (extension == ".jpg" || extension == ".png") //check file type { filename = filename + DateTime.Now.ToString("yymmssfff") + extension; Reg.Image = "~/Pictures/Registeration/" + filename; filename = Path.Combine(Server.MapPath("~/Pictures/Registeration/"), filename); Reg.image_file.SaveAs(filename); TempData["UserData"] = Reg; } else { TempData["extensionerror"] = "Plz check Your Image Type"; } } return(Reg); }
//here user reset password public string UpdatePassword(Companydetail reg, string user_ph) { //encrypted password string enc = reg.User_Password; byte[] encode = new byte[enc.Length]; encode = Encoding.UTF8.GetBytes(reg.User_Password); string enc_password = Convert.ToBase64String(encode); string message = ""; string connection = ConfigurationManager.ConnectionStrings["temp_transport"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); using (SqlCommand cm = new SqlCommand("UpdatePassword", con)) { cm.CommandType = System.Data.CommandType.StoredProcedure; cm.Parameters.AddWithValue("@User_Password", enc_password); cm.Parameters.AddWithValue("@User_PhoneNumber", user_ph); //SqlDataReader dr = cm.ExecuteReader(); if (cm.ExecuteNonQuery() > 0) { message = "1"; } con.Close(); } return(message); } }
public List <Companydetail> VehicleLogin(Companydetail log) { List <Companydetail> reglist = new List <Companydetail>(); string connection = ConfigurationManager.ConnectionStrings["temp_transport"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); using (SqlCommand cm = new SqlCommand("sp_Vehicle_VehicleLogin", con)) { cm.CommandType = System.Data.CommandType.StoredProcedure; cm.Parameters.AddWithValue("@VehicleNumber", log.VehicleNumber); //vehicle no cm.Parameters.AddWithValue("@PinCode", log.PinCode); //PinCode Companydetail company = new Companydetail(); SqlDataReader dr = cm.ExecuteReader(); if (dr.Read()) { company.Image = dr["Vehicle_ImageUrl"].ToString(); company.VehicleNumber = dr["Vehicle_Number"].ToString(); //here return vehicle no } //else //{ //} reglist.Add(company); } return(reglist); } }
public ActionResult FinalyCustomerRegister(Companydetail REG, string command1) { //firstly we check a code is npot equall string role = (TempData["RegistrationRole"].ToString()); string C; if (TempData["code"] != null) //code recive in send mail method { C = (TempData["code"].ToString()); //code assign in varible c for if check if (REG.VerifyCode == C) //code match ,user enter { Companydetail verifiedUser = TempData["Userdata"] as Companydetail; //tempdata user(user reg form) assign in veifieduser CustomerRegister cust_reg = new CustomerRegister(); if (role == "Sing Up") //its for customer sing up { cust_reg.Customer_register(verifiedUser); //PictureSave(REG); return(RedirectToAction("Login", "Registration", new { id = Session["LoginId"] })); //user sucessfullly registered and goes customer home page } else if (role == "Register")// its for admin { cust_reg.Admin_Register(verifiedUser); // PictureSave(REG); List <Companydetail> Reg = new List <Companydetail>(); Reg.Add(verifiedUser); Session["UserData"] = Reg; return(RedirectToAction("Login", "Registration", new { id = Session["LoginId"] })); //user sucessfullly registered and goes admin home page } else if (role == "Registered") { //PictureSave(REG); cust_reg.Driver_Register(verifiedUser); return(RedirectToAction("Login", "Registration", new { id = Session["LoginId"] })); //user sucessfullly registered and goes admin home page } else if (role == "Reset Password") { return(RedirectToAction("UpdatePassword", "Registration", new { id = Session["LoginId"] })); //user sucessfullly registered and goes update home page } } else { TempData["WrongCode"] = "Yor code is not verified <br/> Plz TRY Again"; //code is not verified } } else { TempData["Errormessage"] = "Enter your 5 digit code"; //code is not entered, } if (command1 == "Resend Code") //here is code is resend code and redirect to verify code page { string numbers = "0123456789"; Random objrandom = new Random(); string strrandom = string.Empty; for (int i = 0; i < 5; i++) { int temp = objrandom.Next(0, numbers.Length); strrandom += temp; } ViewBag.otp = strrandom; TempData["code"] = strrandom; TempData.Keep(); Companydetail verifiedUser = TempData["Userdata"] as Companydetail; string ahsan = verifiedUser.UserFirstName; WebMail.Send(verifiedUser.UserEmail, "Well Come '" + verifiedUser.UserLastName + "_" + verifiedUser.UserLastName + "' Sindhu Online Transport Company", "Dear Sir,<br/> You are Register this mobile NO :" + verifiedUser.User_PhoneNumber + "<br/><br/> Your are Register With Email :" + verifiedUser.UserEmail + "<br/><br/>Your Verfy Code Is :" + strrandom , null, null, null, true, null, null, null, null, null, null); TempData.Keep(); TempData["ResendMessage"] = "Check Your Email You get 5 digit Verify Code"; //code is not entered, return(RedirectToAction("VerfyCode", "Registration", new { id = Session["LoginId"] })); } return(RedirectToAction("VerfyCode", "Registration")); }
//here after verify user save in database also forgin key store public string Admin_Register(Companydetail verifiedUser) { //encrypted password string enc = verifiedUser.User_Password; byte[] encode = new byte[enc.Length]; encode = Encoding.UTF8.GetBytes(verifiedUser.User_Password); string enc_password = Convert.ToBase64String(encode); string user_id = ""; string connection = ConfigurationManager.ConnectionStrings["temp_transport"].ConnectionString; using (SqlConnection con = new SqlConnection(connection)) { con.Open(); using (SqlCommand cmd = new SqlCommand("Admin_Registration", con)) { cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@User_FirstName", verifiedUser.UserFirstName); cmd.Parameters.AddWithValue("@User_LastName", verifiedUser.UserLastName); cmd.Parameters.AddWithValue("@User_PhoneNumber", verifiedUser.User_PhoneNumber); cmd.Parameters.AddWithValue("@User_Address", verifiedUser.UserAddress); cmd.Parameters.AddWithValue("@User_Cnic", verifiedUser.UserCnic); cmd.Parameters.AddWithValue("@User_Email", verifiedUser.UserEmail); cmd.Parameters.AddWithValue("@User_Password", enc_password); cmd.Parameters.AddWithValue("@User_Role_Id", 1); cmd.Parameters.AddWithValue("@User_Image", verifiedUser.Image); cmd.Parameters.AddWithValue("@CompanyName", verifiedUser.user_comp); cmd.Parameters.AddWithValue("@CompanyType", verifiedUser.user_comp_type); cmd.Parameters.AddWithValue("@UserCity", verifiedUser.user_City); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { verifiedUser.UserId = int.Parse(dr["UserId"].ToString()); } //company detail con.Close(); con.Open(); using (SqlCommand cm = new SqlCommand("Company_info", con)) { cm.CommandType = System.Data.CommandType.StoredProcedure; cm.Parameters.AddWithValue("@CompanyRegNum", verifiedUser.Comp_Reg_No); cm.Parameters.AddWithValue("@CompanyOwner", verifiedUser.Comp__owner_name); //cm.Parameters.AddWithValue("@owner_cnic", verifiedUser.owner_cnic); //cm.Parameters.AddWithValue("@owner_ph", verifiedUser.owner_ph); cm.Parameters.AddWithValue("@CompanyVehicleQuanitity", verifiedUser.comp_no_vehicle); cm.Parameters.AddWithValue("@CompanyWorth", verifiedUser.comp_worth); cm.Parameters.AddWithValue("@CompanyAddress", verifiedUser.comp_adress); cm.Parameters.AddWithValue("@CompanyPhoneNumber", verifiedUser.CompanyPhoneNumber); cm.Parameters.AddWithValue("@CompanyUserId", verifiedUser.UserId); cm.ExecuteNonQuery(); con.Close(); return(user_id); } } } }
public ActionResult Login(Companydetail log, int id) { // if ((ModelState.IsValidField("User_PhoneNumber") && ModelState.IsValidField("User_Password")) || (ModelState.IsValidField("VehicleNumber") && ModelState.IsValidField("PinCode"))) { string username = ""; int f_key = id; //here we get forgin key and CustomerRegister login = new CustomerRegister(); if (id == 2) { Session["VehicleNumber"] = login.VehicleLogin(log); var userdata = (List <Companydetail>)Session["VehicleNumber"]; foreach (var s in userdata as List <Companydetail> ) { username = s.VehicleNumber; } } else { //TempData["Userdata"] = login.userlogin(log, f_key); List <Companydetail> Reg = login.userlogin(log, f_key); TempData.Keep(); Session["UserData"] = Reg; var userdata = (List <Companydetail>)Session["Userdata"]; foreach (var s in userdata as List <Companydetail> ) { username = s.UserFirstName; } } if (username != null) { //Session["loginuser"] = userdata.user_first_name; //if (Session["loginuser"] != "") //{ //here cheked id we recive in button and redirect with specfic id if (id == 1) { return(RedirectToAction("Index", "Admin")); } if (id == 4) { //Session["user"] =userdata.user_first_name; return(RedirectToAction("Index", "Customer")); } if (id == 2) { //its goes to driver/vehicle index page //Session["user"] =userdata.user_first_name; return(RedirectToAction("Index", "Vehicle")); } } else { TempData["message"] = "Login failed Try Again"; } } return(View()); }