Пример #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");
            }
        }
    }
Пример #2
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        int coId = (int)Session[WebConstants.Session.REG_CO_ID];
        CompanyTableAdapters.un_co_detailsTableAdapter coTA = new CompanyTableAdapters.un_co_detailsTableAdapter();
        if (coTA.GetCompanyByName(txtCompanyShortName.Text, coId).GetEnumerator().MoveNext())
        {
            SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS);
        }
        else
        {
            coTA.Update(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, cbAutoSave.Checked,
                tbFireWarden.Text, tbFirstAider.Text, cbMultiSups.Checked, tbSupervisor.Text, true, DateTime.Today,
                15, Utility.GetTrialEndDate(DateTime.Today,15),true, coId);
            SetInfoMessage(WebConstants.Messages.Information.RECORD_SAVED);
            Session[WebConstants.Session.WIZARD_STEP] = 2;
            Response.Redirect("~/Register/AddDepartment.aspx");

        }
    }
Пример #3
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        int coId = int.Parse(Request[WebConstants.Request.CO_ID]);
        CompanyTableAdapters.un_co_detailsTableAdapter coTA = new CompanyTableAdapters.un_co_detailsTableAdapter();
        if (coTA.GetCompanyByName(txtCompanyShortName.Text, coId).GetEnumerator().MoveNext())
        {
            SetErrorMessage(WebConstants.Messages.Error.ALREAD_EXISTS);
        }
        else if(Validate())
        {
            if (cbTrial.Checked)
            {
                coTA.Update(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, loggedInUserId, DateTime.Now, cbAutoSave.Checked,
                    tbFireWarden.Text, tbFirstAider.Text, cbMultiSups.Checked, tbSupervisor.Text, cbTrial.Checked, tbTrialStartDate.SelectedDate,
                    int.Parse(tbTrialNumOfDays.Text), GetTrialEndDate(),cbWizard.Checked, coId);
            }
            else
            {
                coTA.Update(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, loggedInUserId, DateTime.Now, cbAutoSave.Checked,
                    tbFireWarden.Text, tbFirstAider.Text, cbMultiSups.Checked, tbSupervisor.Text, cbTrial.Checked, null,null,null,cbWizard.Checked,coId);

            }
            SetInfoMessage(WebConstants.Messages.Information.RECORD_SAVED);
        }
    }