protected void BtnCheckAnswer_Click(object sender, ImageClickEventArgs e) { try { cn.Open(); if (TxtA1.Text == "") { LblAnswerError.Visible = true; LblAnswerError.Text = "Please Enter Security Answers A1"; TxtA1.Focus(); return; } if (TxtA2.Text == "") { LblAnswerError.Visible = true; LblAnswerError.Text = "Please Enter Security Answers A2"; TxtA2.Focus(); return; } if (TxtA3.Text == "") { LblAnswerError.Visible = true; LblAnswerError.Text = "Please Enter Security Answers A3"; TxtA3.Focus(); return; } string chk2 = Session["ccdd"].ToString(); if (TxtA1.Text != "" && TxtA2.Text != "" && TxtA3.Text != "") { string sql = "Select Answer1 ,Answer2 , Answer3 from Manager where Manager_Id=@sid and Answer1=@Answer1 and Answer2=@Answer2 and Answer3=@Answer3"; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("@sid", chk2); cmd.Parameters.AddWithValue("@Answer1", TxtA1.Text); cmd.Parameters.AddWithValue("@Answer2", TxtA2.Text); cmd.Parameters.AddWithValue("@Answer3", TxtA3.Text); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { a1 = dr["Answer1"].ToString(); a2 = dr["Answer2"].ToString(); a3 = dr["Answer3"].ToString(); } } dr.Close(); cn.Close(); if (a1 == TxtA1.Text && a2 == TxtA2.Text && a3 == TxtA3.Text) { BtnUpdate.Visible = true; LblPassword.Visible = true; TxtPassword.Visible = true; BtnCheckAnswer.Enabled = false; LblAnswerError.Visible = true; LblAnswerError.Text = "Information Matched"; LblMessage.Visible = true; LblMessage.Text = "Please Wait for a while after click update A confirmation mail will be send to you."; } else { LblAnswerError.Visible = true; LblAnswerError.Text = "Please enter Valid Security Answers "; } } else { if (TxtA1.Text == "") { Response.Write("Please enter Question 1 Answer "); TxtA1.Focus(); return; } if (TxtA2.Text == "") { Response.Write("Please enter Question 2 Answer "); TxtA2.Focus(); return; } if (TxtA3.Text == "") { Response.Write("Please enter Question 3 Answer "); TxtA3.Focus(); return; } } } catch { } finally { cn.Close(); } }
protected void BtnCheckAnswer_Click(object sender, ImageClickEventArgs e) { try { cn.Open(); if (TxtA1.Text == "") { LblAnswerError.Visible = true; LblAnswerError.Text = "Please Enter Security Answers A1"; TxtA1.Focus(); return; } if (TxtA2.Text == "") { LblAnswerError.Visible = true; LblAnswerError.Text = "Please Enter Security Answers A2"; TxtA2.Focus(); return; } if (TxtA3.Text == "") { LblAnswerError.Visible = true; LblAnswerError.Text = "Please Enter Security Answers A3"; TxtA3.Focus(); return; } if (TxtA1.Text != "" && TxtA2.Text != "" && TxtA3.Text != "") { string sql = "SELECT Debit_Card.Debit_Card_No AS card,Client.Answer1 AS A1, Client.Answer2 AS A2, Client.Answer3 AS A3 FROM Debit_Card INNER JOIN Client ON Debit_Card.Client_Id = Client.Client_Id where Debit_Card.Debit_Card_No=@card and Client.Answer1=@ans1 and Client.Answer2=@ans2 and Client.Answer3=@ans3 "; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("card", TxtDebitCard.Text); cmd.Parameters.AddWithValue("ans1", TxtA1.Text); cmd.Parameters.AddWithValue("ans2", TxtA2.Text); cmd.Parameters.AddWithValue("ans3", TxtA3.Text); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { dc2 = dr["card"].ToString(); a1 = dr["A1"].ToString(); a2 = dr["A2"].ToString(); a3 = dr["A3"].ToString(); } } dr.Close(); cn.Close(); if (dc2 == TxtDebitCard.Text && a1 == TxtA1.Text && a2 == TxtA2.Text && a3 == TxtA3.Text) { BtnUpdate.Visible = true; LblPassword.Visible = true; TxtPassword.Visible = true; BtnCheckAnswer.Enabled = false; LblAnswerError.Visible = true; LblAnswerError.Text = "Information Matched"; LblMessage.Visible = true; LblMessage.Text = "Please Wait for a while after click update A confirmation mail will be send to you."; } else { LblAnswerError.Visible = true; LblAnswerError.Text = "Please enter Valid Security Answers "; } } else { if (TxtA1.Text == "") { Response.Write("Please enter Question 1 Answer "); TxtA1.Focus(); return; } if (TxtA2.Text == "") { Response.Write("Please enter Question 2 Answer "); TxtA2.Focus(); return; } if (TxtA3.Text == "") { Response.Write("Please enter Question 3 Answer "); TxtA3.Focus(); return; } } } catch { } finally { cn.Close(); } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { try { try { cn.Open(); if (TxtPassportNo.Text != null) { int t1 = int.Parse(TxtPassportNo.Text); if (t1 <= 0) { LblError.Visible = true; LblError.Text = "Please enter Valid Passport Number"; TxtPassportNo.Focus(); return; } if (TxtPassportNo.Text.Length != 7) { LblMsg.Visible = true; LblMsg.Text = "Please Enter 7 digits passport number"; TxtPassportNo.Focus(); return; } if (TxtPassword.Text != "") { if (TxtPassword.Text.Length < 3) { LblError.Visible = true; LblError.Text = "Please Enter atleast 3 character length Password"; LblMsg.Visible = true; LblMsg.Text = "Please Enter atleast 3 character length Password"; TxtPassword.Focus(); LblMsg.Visible = true; return; } } string pas_Id = TxtPassportNo.Text; string sql = "Select PassportNo from Client where PassportNo=@pass_id"; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("pass_id", pas_Id); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { pn1 = dr["PassportNo"].ToString(); } } dr.Close(); cn.Close(); if (pn1 == TxtPassportNo.Text) { LblError.Visible = true; LblError.Text = "Passport Number Already exist"; LblMsg.Visible = true; LblMsg.Text = "Passport Number Already exist"; TxtPassportNo.Focus(); return; } else { LblMsg.Visible = false; } } } catch { } finally { cn.Close(); } if (TxtPassportNo.Text != "" && TxtPassword.Text != "" && TxtEmail.Text != "" && TxtFirstName.Text != "" && TxtLastName.Text != "") { //int chars = TxtPassportNo.Text.Length; if (TxtPassportNo.Text.Length != 7) { LblError.Visible = true; LblMsg.Text = "Please Enter 7 digits passport number"; LblMsg.Visible = true; LblMsg.Text = "Please Enter 7 digits passport number"; TxtPassportNo.Focus(); LblMsg.Visible = true; return; } if (TxtA1.Text == "") { LblError.Visible = true; LblError.Text = "Please Enter Security Answers A1"; TxtA1.Focus(); return; } if (TxtA2.Text == "") { LblError.Visible = true; LblError.Text = "Please Enter Security Answers A2"; TxtA2.Focus(); return; } if (TxtA3.Text == "") { LblError.Visible = true; LblError.Text = "Please Enter Security Answers A3"; TxtA3.Focus(); return; } LblError.Visible = false; string dob = ddlDay.Text + "/" + ddlMonth.Text + "/" + ddlYear.Text; cn.Open(); DateTimeFormatInfo StartDate = new DateTimeFormatInfo(); StartDate.ShortDatePattern = "dd/MM/yyyy"; StartDate.DateSeparator = "/"; DateTime objDate = Convert.ToDateTime(dob, StartDate); int cnt = 0; SqlCommand cm = new SqlCommand( "INSERT INTO Client (First_Name, Last_Name, DOB, Occupation, Designation, Monthly_Salary,Email, Address, Country, City, PostalCode, Phone_Number, Status, Password, SQ1, Answer1, SQ2, Answer2, SQ3, Answer3, PassportNo, Client_Check) VALUES(@First_Name, @Last_Name, @DOB, @Occupation, @Designation, @Monthly_Salary,@Email, @Address, @Country, @City, @PostalCode, @Phone_Number, @Status, @Password, @SQ1, @Answer1, @SQ2, @Answer2, @SQ3, @Answer3, @PassportNo,@Client_Check)", cn); cm.Parameters.Add("@First_Name", TxtFirstName.Text); cm.Parameters.Add("@Last_Name", TxtLastName.Text); cm.Parameters.Add("@DOB", objDate); cm.Parameters.Add("@Occupation", TxtOccupation.Text); cm.Parameters.Add("@Designation", TxtDesignation.Text); cm.Parameters.Add("@Monthly_Salary", TxtSalary.Text); cm.Parameters.Add("@Email", TxtEmail.Text); cm.Parameters.Add("@Address", TxtAddress.Text); cm.Parameters.Add("@Country", TxtCountry.Text); cm.Parameters.Add("@City", TxtCity.Text); cm.Parameters.Add("@PostalCode", TxtPostalCode.Text); cm.Parameters.Add("@Phone_Number", TxtPhoneNo.Text); cm.Parameters.Add("@Status", TxtStatus.Text); cm.Parameters.Add("@Password", EncryptPasswrod(TxtPassword.Text)); cm.Parameters.Add("@SQ1", TxtQ1.Text); cm.Parameters.Add("@Answer1", TxtA1.Text); cm.Parameters.Add("@SQ2", TxtQ2.Text); cm.Parameters.Add("@Answer2", TxtA2.Text); cm.Parameters.Add("@SQ3", TxtQ3.Text); cm.Parameters.Add("@Answer3", TxtA3.Text); cm.Parameters.Add("@PassportNo", TxtPassportNo.Text); cm.Parameters.Add("@Client_Check", cnt); cm.ExecuteNonQuery(); cm.Clone(); //cmd.CommandText = "Insert INTO Client (First_Name, Last_Name, DOB, Occupation, Designation, Monthly_Salary, Address, Country, City, PostalCode, Phone_Number, Status, Password, SQ1, Answer1, SQ2, Answer2, SQ3, Answer3, PassportNo) VALUES ('" + TxtFirstName.Text + "','" + TxtLastName.Text + "','" + myDateTime + "','" + TxtOccupation.Text + "','" + TxtDesignation.Text + "','" + TxtSalary.Text + "','" + TxtAddress.Text + "','" + TxtCountry.Text + "','" + TxtCity.Text + "','" + TxtPostalCode.Text + "','" + TxtPhoneNo.Text + "','" + TxtStatus.Text + "','" + TxtPassword.Text + "','" + TxtQ1.Text + "','" + TxtA1.Text + "','" + TxtQ2.Text + "','" + TxtA2.Text + "','" + TxtQ3.Text + "','" + TxtA3.Text + "', '" + TxtPassportNo.Text + "')"; //cmd.ExecuteNonQuery(); //cmd.Clone(); cn.Close(); Response.Write("Contact Added Successfully!"); try { cn.Open(); string sql = "Select Client_Id from Client where PassportNo=@tp"; SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = sql; cmd.Parameters.AddWithValue("tp", TxtPassportNo.Text); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { cd = dr["Client_Id"].ToString(); } } dr.Close(); cn.Close(); } catch { } finally { cn.Close(); insertaccount(); Session["cd"] = cd; Response.Redirect("~/Client/Register_Debit_Card.aspx", false); } { LblMsg.Visible = false; } } else { if (TxtPassword.Text == "") { LblError.Visible = true; LblError.Text = "Please enter passowrd"; TxtPassword.Focus(); } if (TxtPassword.Text != "") { if (TxtPassportNo.Text.Length != 3) { LblError.Visible = true; LblMsg.Text = "Please Enter atleast 3 character length Password"; LblMsg.Visible = true; LblMsg.Text = "Please Enter atleast 3 character length Password"; TxtPassword.Focus(); LblMsg.Visible = true; return; } } if (TxtPassportNo.Text == "") { LblError.Visible = true; LblError.Text = "Please enter Passport Number"; TxtPassportNo.Focus(); } if (TxtEmail.Text == "") { LblError.Visible = true; LblError.Text = "Please Enter Email"; TxtEmail.Focus(); } if (TxtFirstName.Text == "") { LblError.Visible = true; LblError.Text = "Please enter FirstName"; TxtFirstName.Focus(); } if (TxtLastName.Text == "") { LblError.Visible = true; LblError.Text = "Please enter Last Name"; TxtLastName.Focus(); } return; } } catch (Exception ex) { Response.Write(ex.Message); } finally { cn.Close(); } }