protected void cmdUpdate_Click(object sender, EventArgs e) { using (PTCLEntities db = new PTCLEntities()) { if (Session["UserID"] != null) { int UserID = Convert.ToInt32(Session["UserID"]); tblPtclUser u = db.tblPtclUsers.FirstOrDefault(v => v.UserID == UserID); u.FirstName = txtMyName.Text; u.LastName = txtLastName.Text; u.EmailAddress = txtEmail.Text; u.Phone = txtPhone.Text; u.Cnic = txtCnic.Text; //u.Password = txtPassword.Text; u.landline = txtLandLineNumber.Text; var password = txtPassword.Text; var salt = CreateSalt(); var hash = HashPassword(password, salt); u.LocationID = Convert.ToInt32(ddlLocationCode.SelectedValue); u.Password = (Convert.ToBase64String(hash)); if (FileUpload.HasFile) { FileUpload.SaveAs(Server.MapPath("../../UploadFiles/CustomerProfile/" + FileUpload.FileName)); u.CustomerDP = FileUpload.FileName; } else { u.CustomerDP = ""; } var check = db.uniqueEmail(txtEmail.Text).ToList(); var check1 = db.spUniqueLandline(txtLandLineNumber.Text).ToList(); if (check.Count == 1) { if (check1.Count == 1) { db.tblPtclUsers.Add(u); db.SaveChanges(); lblMsg.Text = "Registration Completed Succcessfully"; } else { lblMsg.Text = "LandLine Already Takken"; } } else { lblMsg.Text = "Email Already Takken"; } } /*var check = db.uniqueEmail(txtEmail.Text).ToList(); * var check1 = db.spUniqueLandline(txtLandLineNumber.Text).ToList(); * * if (u.landline == txtLandLineNumber.Text || u.EmailAddress == txtEmail.Text) * { * db.SaveChanges(); * lblMsg.Text = "Registration Completed Succcessfully"; * } * else if (check.Count == 0) * { * if (check1.Count == 0) * { * db.SaveChanges(); * lblMsg.Text = "Registration Completed Succcessfully"; * } * else * { * lblMsg.Text = "LandLine Already Takken"; * } * } * else * lblMsg.Text = "Email Already Takken"; * }*/ } }
//Hashing End8 */ protected void cmdRegister_Click(object sender, EventArgs e) { using (PTCLEntities db = new PTCLEntities()) { tblPtclUser u = new tblPtclUser(); u.FirstName = txtFirstName.Text; u.LastName = txtLastName.Text; u.EmailAddress = txtEmail.Text; u.Cnic = txtCnic.Text; u.Phone = txtPhone.Text; u.Status = true; u.landline = txtLandLineNumber.Text; //Location Code u.LocationID = Convert.ToInt32(ddlLocationCode.SelectedValue); if (FileUpload.HasFile) { FileUpload.SaveAs(Server.MapPath("UploadFiles/CustomerProfile/" + FileUpload.FileName)); u.CustomerDP = FileUpload.FileName; } else { u.CustomerDP = ""; } //u.Password = txtPassword.Text; //hashing password start var password = txtPassword.Text; var salt = CreateSalt(); var hash = HashPassword(password, salt); //Response.Write(Convert.ToBase64String(hash)); u.Password = (Convert.ToBase64String(hash)); //hashing password end var check = db.uniqueEmail(txtEmail.Text).ToList(); var check1 = db.spUniqueLandline(txtLandLineNumber.Text).ToList(); //Response.Write(check.Count); if (check.Count == 0) { if (check1.Count == 0) { db.tblPtclUsers.Add(u); db.SaveChanges(); lblMsg.Text = "Registration Completed Succcessfully"; } else { lblMsg.Text = "LandLine Already Takken"; } } else { lblMsg.Text = "Email Already Takken"; } } }