Пример #1
0
        private int StepSection1Next()
        {
            int step = -1;

            // Search Section
            int companyId = Int32.Parse(Session["companyID"].ToString());
            JlinerAddMasterAreaGateway jlinerAddMasterAreaGateway = new JlinerAddMasterAreaGateway(jlinerAddTDS);

            if ((tbxRecordIdForSearch.Text.Trim() == "") && (tbxStreetForSearch.Text.Trim() == ""))
            {
                jlinerAddMasterAreaGateway.LoadByCompaniesId(companyId, int.Parse((string)ViewState["client"]));
                if (jlinerAddMasterAreaGateway.Table.Rows.Count > 0)
                {
                    step = 1;
                }
            }
            else
            {
                if (tbxStreetForSearch.Text.Trim() == "")
                {
                    jlinerAddMasterAreaGateway.LoadByCompaniesIdRecordId(companyId, int.Parse((string)ViewState["client"]), tbxRecordIdForSearch.Text.Trim());
                    if (jlinerAddMasterAreaGateway.Table.Rows.Count == 1)
                    {
                        step = 2;
                        hdfRecordId.Value = tbxRecordIdForSearch.Text.Trim();
                        hdfSelectedId.Value = jlinerAddMasterAreaGateway.GetId(hdfRecordId.Value).ToString();
                        hdfStreet.Value = jlinerAddMasterAreaGateway.GetStreet(hdfRecordId.Value);
                        hdfUsmh.Value = jlinerAddMasterAreaGateway.GetUSMH(hdfRecordId.Value);
                        hdfDsmh.Value = jlinerAddMasterAreaGateway.GetDSMH(hdfRecordId.Value);
                        hdfActualLength.Value = jlinerAddMasterAreaGateway.GetActualLength(hdfRecordId.Value);
                    }
                    else
                    {
                        jlinerAddMasterAreaGateway.LoadByCompaniesIdRecordId(companyId, int.Parse((string)ViewState["client"]), "%" + tbxRecordIdForSearch.Text.Trim() + "%");
                        if (jlinerAddMasterAreaGateway.Table.Rows.Count > 0)
                        {
                            step = 1;
                        }

                    }
                }

                if (step == -1)
                {
                    jlinerAddMasterAreaGateway.LoadByCompaniesIdRecordIdStreet(companyId, int.Parse((string)ViewState["client"]), "%" + tbxRecordIdForSearch.Text.Trim() + "%", "%" + tbxStreetForSearch.Text.Trim() + "%");
                    if (jlinerAddMasterAreaGateway.Table.Rows.Count > 0)
                    {
                        step = 1;
                    }
                }
            }

            // Store datasets
            Session["jlinerAddTDS"] = jlinerAddTDS;
            masterArea = jlinerAddTDS.MasterArea;
            Session["masterArea"] = masterArea;

            // Databind
            grdSection.DataBind();

            // Check next step
            if (step == -1)
            {
                cvSection1.IsValid = false;
            }
            return step;
        }