protected void register_click(object sender, EventArgs e) { string company_name = txt_company_name.Text; string email = txt_email.Text; string phoneNumber = txt_phoneNumber.Text; string password = txt_password.Text; string comeFrom = dropdown_comeFrom.SelectedValue; string government_code = ""; if (comeFrom.Equals("Government")) { government_code = txt_government_code.Text; if ((!file_CEO_ID.HasFile) || (!file_company_certificate.HasFile) || (!file_their_permissions.HasFile) || (string.IsNullOrWhiteSpace(company_name)) || (string.IsNullOrWhiteSpace(email)) || (string.IsNullOrWhiteSpace(phoneNumber)) || (string.IsNullOrWhiteSpace(password)) || (string.IsNullOrWhiteSpace(government_code))) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('All fields required.');", true); return; } } else { if ((!file_CEO_ID.HasFile) || (!file_company_certificate.HasFile) || (!file_their_permissions.HasFile) || (string.IsNullOrWhiteSpace(company_name)) || (string.IsNullOrWhiteSpace(email)) || (string.IsNullOrWhiteSpace(phoneNumber)) || (string.IsNullOrWhiteSpace(password))) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('All fields required.');", true); return; } } string CEO_ID = PutFile(file_CEO_ID); string TheirPermissions = PutFile(file_their_permissions); string CompanyCertificate = PutFile(file_company_certificate); CompanyRepo CompanyRepo = new CompanyRepo(); string result = CompanyRepo.addCompany(new tbl_company { ceoID_path = CEO_ID, comeFrom = comeFrom, company_name = company_name, companyCertificate_path = CompanyCertificate, email = email, isConfirmed = false, password = password, permissions_path = TheirPermissions, phoneNumber = phoneNumber }, government_code); if (result.Equals("not correct")) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Government code not corrected.');", true); return; } if (result.Equals("already")) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('This email address is already exist.');", true); return; } if (result.Equals("true")) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Account successfully created.');", true); txt_company_name.Text = ""; txt_email.Text = ""; txt_government_code.Text = ""; txt_password.Text = ""; txt_phoneNumber.Text = ""; return; } if (result.Equals("false")) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Something went wrong.');", true); return; } }