protected void btnuseradd_Click(object sender, EventArgs e) { if (txtname.Text != "" && txtuname.Text != "" && txtemail.Text != "" && ddlgender.SelectedIndex != 0 && txtdoj.Text != "" && txtdob.Text != "" && ddldep.SelectedIndex != 0 && Request.Form[ddldesi.UniqueID] != null && Request.Form[ddlgrade.UniqueID] != null && ddlregion.SelectedIndex != 0 && ddlreportingofficer.SelectedIndex != 0) { if (txtemail.Text.Trim().Length <= 30) { namematch = name.Match(txtname.Text.Trim()); if (namematch.Success) { unamematch = uname.Match(txtuname.Text.Trim()); if (unamematch.Success) { match = regex.Match(txtemail.Text.Trim()); if (match.Success) { bus.name = txtname.Text.Trim(); bus.user_name = txtuname.Text.Trim(); bus.email = txtemail.Text.Trim(); bus.gender = ddlgender.SelectedItem.ToString().Trim(); bus.doj = DateTime.Parse(txtdoj.Text.Trim()); bus.dob = DateTime.Parse(txtdob.Text.Trim()); bus.dep = int.Parse(ddldep.SelectedValue.ToString()); bus.desi = int.Parse(Request.Form[ddldesi.UniqueID]); bus.grade = int.Parse(Request.Form[ddlgrade.UniqueID]); bus.region = int.Parse(ddlregion.SelectedValue.ToString()); bus.report_offid = int.Parse(ddlreportingofficer.SelectedValue.ToString()); bus.islead = chkIslead.Checked ? "Y" : "N"; int r = bus.add_user(); if (r == 1) { clearfeilds(); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "success();", true); } else if (r == 2) { clearfeilds(); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "error_dupli();", true); } else if (r == 4) { clearfeilds(); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "error_dupliemail();", true); } else { clearfeilds(); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "error();", true); } } else { ddldep.SelectedIndex = 0; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "errorinvalid();", true); }// end email regex } else { ddldep.SelectedIndex = 0; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "erroruname();", true); }// end uname regex } else { ddldep.SelectedIndex = 0; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "errorname();", true); } // end name regex } else { ddldep.SelectedIndex = 0; ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "errorlength();", true); }// end length email } else { clearfeilds(); ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", "error1();", true); } }