请在条件允许的情况下帮助我成功执行以下任务.....提前表示感谢 [英] Plz plz help me to execute successfuuly the following if conditions........Thanx in advance
本文介绍了请在条件允许的情况下帮助我成功执行以下任务.....提前表示感谢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void btnsave_Click(object sender, EventArgs e)
{
if (txtaccount1.Text == "")
{
label17.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtaccount1.Text!="")
{
label17.Text = "";
label31.Text = "";
}
else if (txtaccounttitle.Text == "")
{
label18.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtaccounttitle.Text != "")
{
label18.Text = "";
label31.Text = "";
}
else if (txtinitial.Text == "")
{
label19.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtinitial.Text != "")
{
label19.Text = "";
label31.Text = "";
}
else if (cboaccounttype.SelectedIndex == -1)
{
label27.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (cboaccounttype.SelectedIndex != -1)
{
label27.Text = "";
label31.Text = "";
}
else if (txtaccountnature.Text == "")
{
label28.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtaccountnature.Text != "")
{
label28.Text = "";
label31.Text = "";
}
else if (txtpostal.Text == "")
{
label25.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtpostal.Text != "")
{
label25.Text = "";
label31.Text = "";
}
else if (cbodistrict.SelectedIndex == -1)
{
label24.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (cbodistrict.SelectedIndex != -1)
{
label24.Text = "";
label31.Text = "";
}
else
if (cbocity.SelectedIndex == -1)
{
label23.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (cbocity.SelectedIndex != -1)
{
label23.Text = "";
label31.Text = "";
}
else if (txtname1.Text == "")
{
label20.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtname1.Text != "")
{
label20.Text = "";
label31.Text = "";
}
else if (txtfather1.Text == "")
{
label21.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtfather1.Text != "")
{
label21.Text = "";
label31.Text = "";
}
else if (txthusband1.Text == "")
{
label22.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txthusband1.Text != "")
{
label22.Text = "";
label31.Text = "";
}
else
if (txtoccupation1.Text == "")
{
label30.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtoccupation1.Text != "")
{
label30.Text = "";
label31.Text = "";
}
else if (txtmobile1.Text == "")
{
label26.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtmobile1.Text != "")
{
label26.Text = "";
label31.Text="";
}
else if (txtcnic1.Text == "")
{
label29.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (txtcnic1.Text != "")
{
label29.Text = "";
label31.Text = "";
}
else if (radioButton1.Checked == false && radioButton2.Checked == false)
{
label33.Text = "<<";
label31.Text = "All Fields are Required";
}
else if (radioButton1.Checked != false && radioButton2.Checked != false)
{
label33.Text = "";
label31.Text = "";
}
else
{
if (!Regex.Match(txtloan.Text, @"^[0-9]*$").Success)
MessageBox.Show("Invalid Loan id\nOnly digits Allow");
else if (!Regex.Match(txtaccount.Text, @"^[0-9]*-[0-9]{1}$").Success)
MessageBox.Show("Invalid account no:\nShould be of type e.g 8459-5");
else if (!Regex.Match(txtname.Text, @"^[A-Za-z][A-Za-z. ]*$").Success)
MessageBox.Show("Invalid Name");
else if (!Regex.Match(txtfather.Text, @"^[A-Za-z][A-Za-z. ]*$").Success)
MessageBox.Show("Invalid father/husband Name");
else if (!Regex.Match(txtcnic.Text, @"^[0-9]{5}-[0-9]{7}-[0-9]{1}$").Success)
MessageBox.Show("Invalid CNIC");
else if (!Regex.Match(txtmobile.Text, @"^[0-9]{11}$").Success)
MessageBox.Show("Invalid mobile no");
else if (!Regex.Match(txtmobile.Text, @"^[0-9]{11}$").Success)
MessageBox.Show("Invalid mobile no");
else if (radioButton1.Checked == true)
a = radioButton1.Text;
else if (radioButton2.Checked == true)
a = radioButton2.Text;
else
{
String query = "insert into Accounts(Account_No,Account_title,Entry_Date,Initial_Deposite,Account_type,Account_Nature,Postal_Code,District,City,Name,Father_name,Husband_name,Occupation,Mobile,CNIC,Gender)values(@Account_No,@Account_title,@Entry_Date,@Initial_Deposite,@Account_type,@Account_Nature,@Postal_Code,@District,@city,@Name,@Father_name,@Husband_name,@Occupation,@Mobile,@CNIC,@Gender)";
SqlCommand cmd = new SqlCommand(query, cn);
cmd.Prepare();
cmd.Parameters.AddWithValue("@Account_No", txtaccount1.Text);
cmd.Parameters.AddWithValue("@Account_title", txtaccounttitle.Text);
cmd.Parameters.AddWithValue("@Entry_Date", dateTimePicker1.Value.Date);
cmd.Parameters.AddWithValue("@Initial_Deposite", txtinitial.Text);
cmd.Parameters.AddWithValue("@Account_type", cboaccounttype.SelectedItem);
cmd.Parameters.AddWithValue("@Account_Nature", txtaccountnature.Text);
cmd.Parameters.AddWithValue("@Postal_code", txtpostal.Text);
cmd.Parameters.AddWithValue("@District", cbodistrict.SelectedItem);
cmd.Parameters.AddWithValue("@City", cbocity.SelectedItem);
cmd.Parameters.AddWithValue("@Name", txtname1.Text);
cmd.Parameters.AddWithValue("@Father_name", txtfather1.Text);
cmd.Parameters.AddWithValue("@Husband_name", txthusband1.Text);
cmd.Parameters.AddWithValue("@Occupation", txtoccupation1.Text);
cmd.Parameters.AddWithValue("@Mobile", txtmobile1.Text);
cmd.Parameters.AddWithValue("@CNIC", txtcnic1.Text);
cmd.Parameters.AddWithValue("@Gender", a);
cmd.ExecuteNonQuery();
MessageBox.Show("record stored");
}
}
}
推荐答案
").成功) MessageBox.Show(" 其他 如果(!Regex.Match(txtaccount.Text, @"
").Success) MessageBox.Show("Invalid Loan id\nOnly digits Allow"); else if (!Regex.Match(txtaccount.Text, @"^[0-9]*-[0-9]{1}
" ).成功) MessageBox.Show(" )); 其他 如果(!Regex.Match(txtname.Text, @"
").Success) MessageBox.Show("Invalid account no:\nShould be of type e.g 8459-5"); else if (!Regex.Match(txtname.Text, @"^[A-Za-z][A-Za-z. ]*
" ) .成功) MessageBox.Show(" ); 其他 如果(!Regex.Match(txtfather.Text, @"
").Success) MessageBox.Show("Invalid Name"); else if (!Regex.Match(txtfather.Text, @"^[A-Za-z][A-Za-z. ]*
这篇关于请在条件允许的情况下帮助我成功执行以下任务.....提前表示感谢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文