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,Gender,Marital_status)values(@Account_No,@Account_title,@Entry_Date,@Initial_Deposite,@Account_type,@Account_Nature,@Postal_Code,@District,@city,@Name,@Father_name,@Husband_name,@Occupation,@Mobile,@Gender,@Marital_status)";
SqlCommand cmd = new SqlCommand(query, cn);
cmd.Prepare();
cmd.Parameters.AddWithValue("@Account_No", txtac1.Text + "-" + txtac2.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", txttype.Text);
cmd.Parameters.AddWithValue("@Account_Nature", cboaccountnature.SelectedItem);
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", cbocode.Text + "-" + txtmobile1.Text);
cmd.Parameters.AddWithValue("@Marital_status", cbomarital.Text);
if (rdomale.Checked == true)
cmd.Parameters.AddWithValue("@Gender", rdomale.Text);
else if (rdofemale.Checked == true)
cmd.Parameters.AddWithValue("@Gender", rdofemale.Text);
cmd.ExecuteNonQuery();
MessageBox.Show("Record Stored Successfully", "Success Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}