protected void Page_Load(object sender, EventArgs e) { String strCompany = Request.Form["NewCompany"].ToString(); int AccountOwner = Int32.Parse(Request.Form["NewAccountOwner"].ToString()); String strWebSite = String.Empty; var firstName = ""; var lastName = ""; var emailAddress = ""; var isSkipChecked = ""; if (!String.IsNullOrEmpty(Request.Form["FirstName"])) { firstName = Request.Form["FirstName"].ToString(); } if (!String.IsNullOrEmpty(Request.Form["LastName"])) { lastName = Request.Form["LastName"].ToString(); } if (!String.IsNullOrEmpty(Request.Form["EmailAddress"])) { emailAddress = Request.Form["EmailAddress"].ToString(); } if (!String.IsNullOrEmpty(Request.Form["ISSkipClicked"])) { isSkipChecked = Request.Form["ISSkipClicked"].ToString(); } if (!String.IsNullOrEmpty(Request.Form["NewWebsite"])) { strWebSite = Request.Form["NewWebsite"].ToString(); } DeltoneCRMDAL dal = new DeltoneCRMDAL(); String Comp_Count = dal.CompanyNameCount(strCompany); var userName = Session["LoggedUser"].ToString(); if (Int32.Parse(Comp_Count) > 0) { SendNotificationEmail(strCompany, userName); Response.Write("ERROR"); } else { if (!string.IsNullOrEmpty(isSkipChecked)) { var loggedInUserId = Convert.ToInt32(Session["LoggedUserID"].ToString()); Response.Write(dal.AddNewCompany(strCompany, strWebSite, AccountOwner, loggedInUserId)); } else { var connectionString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString; var contactDal = new ContactDAL(connectionString); var contact = contactDal.GetContactByContactNameandEmail(firstName, lastName, emailAddress); if (contact.ContactId > 0) { SendNotificationEmail(strCompany, userName); Response.Write("ERROR"); } else { var loggedInUserId = Convert.ToInt32(Session["LoggedUserID"].ToString()); Response.Write(dal.AddNewCompany(strCompany, strWebSite, AccountOwner, loggedInUserId)); } } } }