protected void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         DepartmentTableAdapters.DepartmentSelectCommandTableAdapter dep_Adapter = new DepartmentTableAdapters.DepartmentSelectCommandTableAdapter();
         DataTable dt = dep_Adapter.GetDepartmentByShortName(txtCompanyShortName.Text, loggedInUserCoId);
         if (dt.Rows.Count == 0)
         {
             int coId = 0;
             if (loggedInUserRole == WebConstants.Roles.Admin)
             {
                 coId = int.Parse(ddlCompany.SelectedValue);
             }
             else
             {
                 coId = loggedInUserCoId;
             }
             dep_Adapter.InsertDepartment(coId, false, txtCompanyShortName.Text, txtCompanyLongName.Text, txtContactTitle.Text, txtContactInitial.Text.Trim(), txtForename.Text.Trim(), txtSurname.Text.Trim(), txtAddressNo.Text.Trim(), txtAddress1.Text.Trim(), txtAddress2.Text.Trim(), txtAddress3.Text.Trim(), txtAddress4.Text.Trim(), txtAddress5.Text.Trim(), txtPostalCode.Text.Trim(),GetFullAddress(), txtTele.Text.Trim(), txtTele1.Text.Trim(), txtFax.Text.Trim(), txtEmail.Text.Trim(), txtCoNotes.Text.Trim(), loggedInUserId, DateTime.Now, loggedInUserId, DateTime.Now);
             Response.Redirect("DepartmentList.aspx");
         }
         else
         {
             SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS);
         }
     }
     catch
     {
         SetErrorMessage(WebConstants.Messages.Error.CONNECTION_ERROR);
     }
 }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Session[WebConstants.Session.REG_CO_ID] != null)
     {
         int coId = (int)Session[WebConstants.Session.REG_CO_ID];
         DepartmentTableAdapters.DepartmentSelectCommandTableAdapter dep_Adapter = new DepartmentTableAdapters.DepartmentSelectCommandTableAdapter();
         DataTable dt = dep_Adapter.GetDepartmentByShortName(txtCompanyShortName.Text, coId);
         if (dt.Rows.Count == 0)
         {
             IEnumerator ie = dep_Adapter.InsertAndReturn(coId, false, txtCompanyShortName.Text, txtCompanyLongName.Text, txtContactTitle.Text, txtContactInitial.Text.Trim(), txtForename.Text.Trim(), txtSurname.Text.Trim(), txtAddressNo.Text.Trim(), txtAddress1.Text.Trim(), txtAddress2.Text.Trim(), txtAddress3.Text.Trim(), txtAddress4.Text.Trim(), txtAddress5.Text.Trim(), txtPostalCode.Text.Trim(), GetFullAddress(), txtTele.Text.Trim(), txtTele1.Text.Trim(), txtFax.Text.Trim(), txtEmail.Text.Trim(), txtCoNotes.Text.Trim(), null, DateTime.Now, null, DateTime.Now).GetEnumerator();
             if (ie.MoveNext())
             {
                 Department.DepartmentSelectCommandRow department = (Department.DepartmentSelectCommandRow)ie.Current;
                 Session[WebConstants.Session.REG_DEPT_ID] = department.dept_id;
                 Session[WebConstants.Session.WIZARD_STEP] = 3;
                 Response.Redirect("~/Register/AddUser.aspx");
             }
         }
         else
         {
             SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS);
         }
     }
 }