예제 #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        CompanyTableAdapters.un_co_detailsTableAdapter coTA = new CompanyTableAdapters.un_co_detailsTableAdapter();
        if (coTA.GetCompanyByName(txtCompanyShortName.Text, null).GetEnumerator().MoveNext())
        {
            SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS);
        }
        else
        {
            IEnumerator ie = coTA.InsertAndReturn(false, txtCompanyShortName.Text, txtCompanyLongName.Text, txtContactTitle.Text, txtContactInitial.Text, txtForename.Text, txtSurname.Text,
                    txtAddressNo.Text, txtAddress1.Text, txtAddress2.Text, txtAddress3.Text, txtAddress4.Text, txtAddress5.Text, txtPostalCode.Text, getFullAddress(),
                    txtTele.Text, txtTele1.Text, txtFax.Text, txtEmail.Text, txtCoNotes.Text, 0, 0, false,null, DateTime.Now, null,
                    DateTime.Now, cbAutoSave.Checked, tbFireWarden.Text, tbFirstAider.Text, cbMultiSups.Checked, tbSupervisor.Text, true, 1, true,
                    DateTime.Today, 15, Utility.GetTrialEndDate(DateTime.Today,15),true).GetEnumerator();
            if (ie.MoveNext())
            {
                int coId = ((Company.un_co_detailsRow)ie.Current).co_id;
                Session[WebConstants.Session.REG_CO_ID] = coId;
                DepartmentTableAdapters.DepartmentSelectCommandTableAdapter deptTA = new DepartmentTableAdapters.DepartmentSelectCommandTableAdapter();
                IEnumerator ieDept = deptTA.InsertAndReturn(coId,false,txtCompanyShortName.Text,txtCompanyLongName.Text,txtContactTitle.Text, txtContactInitial.Text, txtForename.Text, txtSurname.Text,
                    txtAddressNo.Text, txtAddress1.Text, txtAddress2.Text, txtAddress3.Text, txtAddress4.Text, txtAddress5.Text, txtPostalCode.Text, getFullAddress(),
                    txtTele.Text, txtTele1.Text, txtFax.Text, txtEmail.Text,txtCoNotes.Text,null,DateTime.Now,null,DateTime.Now).GetEnumerator();

                if(ieDept.MoveNext())
                {
                    Session[WebConstants.Session.REG_DEPT_ID] = ((Department.DepartmentSelectCommandRow)ieDept.Current).dept_id;
                }
                SetInfoMessage(WebConstants.Messages.Information.RECORD_SAVED);
                Session[WebConstants.Session.WIZARD_STEP] = 2;
                Response.Redirect("~/Register/AddDepartment.aspx");
            }
        }
    }
 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);
         }
     }
 }