Ejemplo n.º 1
0
        private bool StepSummaryFinish()
        {
            if (Page.IsValid)
            {
                string type = (rbtnVehicle.Checked) ? type = "Vehicle" : type = "Equipment";
                string code = tbxCode.Text;
                string description = ""; if (tbxDescription.Text != "") description = tbxDescription.Text;
                string vin = ""; if (tbxVinSerialNumber.Text != "") vin = tbxVinSerialNumber.Text;
                string manufacturer = ""; if (tbxManufacturer.Text != "") manufacturer = tbxManufacturer.Text;
                string model = ""; if (tbxModel.Text != "") model = tbxModel.Text;
                string year = ""; if (tbxYear.Text != "") year =tbxYear.Text;
                bool isTowable = (cbxIsTowable.Checked) ? isTowable = true : isTowable = false;

                Int64? licenseCountry = null;
                Int64? licenceState = null;

                if (type == "Vehicle")
                {
                    if (ddlLicenseCountry.SelectedValue != "-1")
                    {
                        licenseCountry = Int64.Parse(ddlLicenseCountry.SelectedValue);

                        if (ddlLicenseState.SelectedValue != "-1" && ddlLicenseState.SelectedValue != "")
                        {
                            licenceState = Int64.Parse(ddlLicenseState.SelectedValue);
                        }
                    }
                }

                string licensePlateNumber = ""; if (tbxLicensePlateNumber.Text != "") licensePlateNumber = tbxLicensePlateNumber.Text;
                string apportionedTagNumber = ""; if (tbxApportionedTagNumber.Text != "") apportionedTagNumber = tbxApportionedTagNumber.Text;
                int companyLevelIdSelected = 0;

                foreach (int companyLevelId in arrayCompanyLevelsSelected)
                {
                    companyLevelIdSelected = companyLevelId;
                }

                UnitsAddTDS dataSet = new UnitsAddTDS();
                dataSet.UnitsAddNew.Merge(unitsAddNew, true);
                UnitsAddNew modelU = new UnitsAddNew(dataSet);
                modelU.Insert(type, code, description, vin, manufacturer, model, year, isTowable, licenseCountry, licenceState, licensePlateNumber, apportionedTagNumber, companyLevelIdSelected);

                unitsAddNew.Rows.Clear();
                unitsAddNew.Merge(modelU.Table);

                // Store database
                Session["unitsAddTDS"] = unitsAddTDS;
                Session["unitsAddNew"] = unitsAddNew;

                Save();

                hdfUpdate.Value = "yes";

                return true;
            }
            else
            {
                return false;
            }
        }
Ejemplo n.º 2
0
        private void Save()
        {
            // Save to database
            DB.Open();
            DB.BeginTransaction();
            try
            {
                int companyId = Convert.ToInt32(Session["companyID"]);

                // Process view
                UnitsAddTDS dataset = new UnitsAddTDS();
                dataset.UnitsAddNew.Merge(unitsAddNew, true);
                dataset.UnitsChecklistRulesTemp.Merge(unitsChecklistRulesTempForAdd, true);

                UnitsAddNew modelUnitsAddNew = new UnitsAddNew(dataset);
                modelUnitsAddNew.Save(arrayCategoriesSelected, companyId);

                DB.CommitTransaction();

                // Store datasets
                unitsAddTDS.AcceptChanges();
                Session["unitsAddTDS"] = unitsAddTDS;
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }