This code supposed to verify if account and phone exist in database if yes throw message that the account and phone already in database, but the code only verifying account instead of account and phone.
The could not work when i added two conditions Account_no and phone. It works with one condition but if more than one it does not work. It only checks with account_no while ignoring the phone number.
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("SELECT Account_No,Phone FROM Customer_Account WHERE Account_No = @Account_No AND Phone=@Phone ", con))
{
cmd.CommandType = CommandType.Text;
// cmd.Parameters.AddWithValue("@Name", this.txtname.Text.Trim());
cmd.Parameters.AddWithValue("@Account_No", this.txtaccountno.Text.Trim());
cmd.Parameters.AddWithValue("@Phone", this.txtphone.Text.Trim());
// cmd.Parameters.AddWithValue("@Registered_Date", this.txtdate.Text.Trim());
con.Open();
string result = Convert.ToString(cmd.ExecuteScalar());
con.Close();
if (string.IsNullOrEmpty(result))
{
Insert(this.txtdate.Text.Trim(), this.ddllocation.SelectedItem.Text.Trim(), this.txtname.Text.Trim(), this.txtphone.Text.Trim(), this.txtemail.Text.Trim(), this.txtaddress.Text.Trim(), this.txtaccountno.Text.Trim(),this.ddlaccountype.SelectedItem.Text.Trim(), this.txtaccountofficer.Text.Trim(), this.txtverifiedby.Text.Trim(), this.ddlpaytype.SelectedItem.Text.Trim(), this.txtcharges.Text.Trim());
// this.ddlitem.SelectedItem.Text = "";
//this.txtqty.Text = "";
// this.txtprice.Text = "";
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Data Submitted Successfully ... !!')", true);
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Alert", "alert('Account Number Already Exists');", true);
}
}
}