Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.IsPostBack == false)
        {
            #region 加载Service Type Filter

            ServiceTypes ServiceTypeManager = new ServiceTypes();
            DataTable    ServiceTypeList    = ServiceTypeManager.GetServiceTypeList(" and (Enabled=1)");
            DataRow      NewServiceTypeRow  = ServiceTypeList.NewRow();
            NewServiceTypeRow["ServiceTypeId"] = DBNull.Value;
            NewServiceTypeRow["Name"]          = "-- select --";
            ServiceTypeList.Rows.InsertAt(NewServiceTypeRow, 0);
            ServiceTypeList.AcceptChanges();

            this.ddlServiceType.DataSource = ServiceTypeList;
            this.ddlServiceType.DataBind();

            #endregion
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CurrUser.userRole.ContactBranch.ToString().IndexOf('1') == -1)
        {
            Response.Redirect("../Unauthorize.aspx");  // have not View Power
            return;
        }

        sHasCreate            = CurrUser.userRole.ContactBranch.ToString().IndexOf('2') > -1 ? "1" : "0";
        sHasModify            = CurrUser.userRole.ContactBranch.ToString().IndexOf('3') > -1 ? "1" : "0";
        sHasDelete            = CurrUser.userRole.ContactBranch.ToString().IndexOf('4') > -1 ? "1" : "0";
        sHasDisable           = CurrUser.userRole.ContactBranch.ToString().IndexOf('5') > -1 ? "1" : "0";
        sHasAddBranch         = CurrUser.userRole.ContactBranch.ToString().IndexOf('6') > -1 ? "1" : "0";
        sHasRemoveBranch      = CurrUser.userRole.ContactBranch.ToString().IndexOf('7') > -1 ? "1" : "0";
        sHasModifyCompany     = CurrUser.userRole.ContactCompany.ToString().IndexOf('3') > -1 ? "1" : "0"; //Company Modify
        sHasModifyServiceType = CurrUser.userRole.ServiceType.ToString().IndexOf('1') > -1 ? "1" : "0";    //Service Type View
        if (sHasDelete == "0")
        {
            btnDelete.Enabled = false;
        }
        if (sHasDisable == "0")
        {
            btnDisable.Enabled = false;
        }

        #region 加载Service Type Filter
        ServiceTypes ServiceTypeManager = new ServiceTypes();
        DataTable    ServiceTypeList    = ServiceTypeManager.GetServiceTypeList(" and (Enabled=1)");
        DataRow      NewServiceTypeRow  = ServiceTypeList.NewRow();
        NewServiceTypeRow["ServiceTypeId"] = "0";
        NewServiceTypeRow["Name"]          = "All Service Types";
        ServiceTypeList.Rows.InsertAt(NewServiceTypeRow, 0);
        ServiceTypeList.AcceptChanges();

        this.ddlServiceType.DataSource = ServiceTypeList;
        this.ddlServiceType.DataBind();

        #endregion

        #region 加载Company Filter
        ContactCompanies ContactCompaniesManager = new ContactCompanies();
        DataSet          ContactCompaniesList    = ContactCompaniesManager.GetList("(Enabled=1) order by Name");
        //if (ContactCompaniesList != null && ContactCompaniesList.Tables[0].Rows.Count > 0)
        //{
        DataRow NewContactCompaniesRow = ContactCompaniesList.Tables[0].NewRow();
        NewContactCompaniesRow["ContactCompanyId"] = "0";
        NewContactCompaniesRow["Name"]             = "All Companies";
        ContactCompaniesList.Tables[0].Rows.InsertAt(NewContactCompaniesRow, 0);
        ContactCompaniesList.Tables[0].AcceptChanges();

        this.ddlCompany.DataSource = ContactCompaniesList.Tables[0];
        this.ddlCompany.DataBind();
        //}

        #endregion

        #region 加载States Filter
        LPWeb.Layouts.LPWeb.Common.USStates.Init(this.ddlStates);
        #endregion

        #region 加载Company列表

        this.BranchSqlDataSource.ConnectionString = LPWeb.DAL.DbHelperSQL.connectionString;

        string sWhere = string.Empty;

        bool bSetCondition = false;

        // Alphabet
        if (this.Request.QueryString["Alphabet"] != null)
        {
            string sAlphabet = this.Request.QueryString["Alphabet"].ToString();
            sWhere += " and (Branch like '" + sAlphabet + "%')";

            bSetCondition = true;
        }

        // Service Type
        if (this.Request.QueryString["ServiceType"] != null)
        {
            string sServiceType = this.Request.QueryString["ServiceType"].ToString();
            if (PageCommon.IsID(sServiceType) == true)
            {
                sWhere += " and (ServiceTypeId =" + SqlTextBuilder.ConvertQueryValue(sServiceType) + ")";
            }
            else
            {
                sWhere += " and (ServiceTypeId =0)";
            }

            bSetCondition = true;
        }

        // Company
        if (this.Request.QueryString["Company"] != null)
        {
            string sCompany = this.Request.QueryString["Company"].ToString();
            if (PageCommon.IsID(sCompany) == true)
            {
                sWhere += " and (ContactCompanyId =" + SqlTextBuilder.ConvertQueryValue(sCompany) + ")";
            }
            else
            {
                sWhere += " and (ContactCompanyId =0)";
            }

            bSetCondition = true;
        }

        // State
        if (this.Request.QueryString["State"] != null)
        {
            string sState = this.Request.QueryString["State"].ToString();
            if (sState != "")
            {
                sWhere += " and ([State] ='" + SqlTextBuilder.ConvertQueryValue(sState) + "')";

                bSetCondition = true;
            }
        }

        int iRowCount = LPWeb.DAL.DbHelperSQL.Count(this.BranchSqlDataSource.SelectParameters["DbTable"].DefaultValue, sWhere);

        // empty data text
        if (iRowCount == 0 && bSetCondition == true)
        {
            this.gridBranchList.EmptyDataText = "There is no partner branch by search criteria,please search again.";
        }
        else
        {
            this.gridBranchList.EmptyDataText = "There is no partner branch.";
        }

        this.AspNetPager1.RecordCount = iRowCount;

        this.BranchSqlDataSource.SelectParameters["Where"].DefaultValue = sWhere;
        this.gridBranchList.DataBind();

        #endregion
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string sReturnJs = "window.location.href='PartnerCompanyList.aspx';";

        #region 权限控制
        sHasCreate       = CurrUser.userRole.ContactBranch.ToString().IndexOf('2') > -1 ? "1" : "0";
        sHasModify       = CurrUser.userRole.ContactBranch.ToString().IndexOf('3') > -1 ? "1" : "0";
        sHasDelete       = CurrUser.userRole.ContactBranch.ToString().IndexOf('4') > -1 ? "1" : "0";
        sHasDisable      = CurrUser.userRole.ContactBranch.ToString().IndexOf('5') > -1 ? "1" : "0";
        sHasAddBranch    = CurrUser.userRole.ContactBranch.ToString().IndexOf('6') > -1 ? "1" : "0";
        sHasRemoveBranch = CurrUser.userRole.ContactBranch.ToString().IndexOf('7') > -1 ? "1" : "0";

        if (sHasDisable == "0")
        {
            lnkDisableBranch.Enabled = false;
        }
        if (sHasDelete == "0")
        {
            lnkDeleteBranch.Enabled = false;
        }
        #endregion

        #region 检查页面参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "CompanyID", QueryStringType.ID);
        if (bIsValid == false)
        {
            PageCommon.WriteJsEnd(this, "Missing required query string.", sReturnJs);
        }
        this.iCompanyID = Convert.ToInt32(this.Request.QueryString["CompanyID"]);

        #endregion

        #region 加载Company信息

        ContactCompanies ContactCompanyManager = new ContactCompanies();
        DataTable        CompanyInfo           = ContactCompanyManager.GetContactCompanyInfo(this.iCompanyID);
        if (CompanyInfo.Rows.Count == 0)
        {
            PageCommon.WriteJsEnd(this, "Invalid query string.", sReturnJs);
        }

        #endregion

        #region 加载Branch列表

        this.BranchSqlDataSource.ConnectionString = LPWeb.DAL.DbHelperSQL.connectionString;

        string sWhere = " and (ContactCompanyId=" + this.iCompanyID + ")";

        bool bSetCondition = false;

        // Alphabet
        if (this.Request.QueryString["Alphabet"] != null)
        {
            string sAlphabet = this.Request.QueryString["Alphabet"].ToString();
            sWhere += " and (Name like '" + sAlphabet + "%')";

            bSetCondition = true;
        }

        int iRowCount = LPWeb.DAL.DbHelperSQL.Count(this.BranchSqlDataSource.SelectParameters["DbTable"].DefaultValue, sWhere);

        // empty data text
        if (iRowCount == 0 && bSetCondition == true)
        {
            this.gridBranchList.EmptyDataText = "There is no Partner Branch by search criteria,please search again.";
        }
        else
        {
            this.gridBranchList.EmptyDataText = "There is no Partner Branch.";
        }

        this.AspNetPager1.RecordCount = iRowCount;

        this.BranchSqlDataSource.SelectParameters["Where"].DefaultValue = sWhere;
        this.gridBranchList.DataBind();

        #endregion

        if (this.IsPostBack == false)
        {
            #region 加载Service Type Filter

            ServiceTypes ServiceTypeManager = new ServiceTypes();
            DataTable    ServiceTypeList    = ServiceTypeManager.GetServiceTypeList(" and (Enabled=1)");
            DataRow      NewServiceTypeRow  = ServiceTypeList.NewRow();
            NewServiceTypeRow["ServiceTypeId"] = DBNull.Value;
            NewServiceTypeRow["Name"]          = "-- select --";
            ServiceTypeList.Rows.InsertAt(NewServiceTypeRow, 0);
            ServiceTypeList.AcceptChanges();

            this.ddlServiceType.DataSource = ServiceTypeList;
            this.ddlServiceType.DataBind();

            #endregion

            #region 绑定Company数据

            this.txtCompanyName.Text          = CompanyInfo.Rows[0]["Name"].ToString();
            this.ddlServiceType.SelectedValue = CompanyInfo.Rows[0]["ServiceTypeId"].ToString();


            if (CompanyInfo.Rows[0]["Enabled"] == DBNull.Value)
            {
                this.chkEnabled.Checked = true;
            }
            else
            {
                this.chkEnabled.Checked = Convert.ToBoolean(CompanyInfo.Rows[0]["Enabled"]);
            }

            this.txtAddress.Text        = CompanyInfo.Rows[0]["Address"].ToString();
            this.txtCity.Text           = CompanyInfo.Rows[0]["City"].ToString();
            this.ddlState.SelectedValue = CompanyInfo.Rows[0]["State"].ToString();
            this.txtZip.Text            = CompanyInfo.Rows[0]["Zip"].ToString();
            this.tbWebsite.Text         = string.Format("{0}", CompanyInfo.Rows[0]["Website"].ToString());

            #endregion
        }
    }
Exemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "DelContactID", QueryStringType.ID);
        if (bIsValid == false)
        {
            PageCommon.WriteJsEnd(this, "Messing required query string.", PageCommon.Js_RefreshParent);
        }

        this.iDelContactID = Convert.ToInt32(this.Request.QueryString["DelContactID"]);

        // 检查Contact是否存在
        string    sSql           = "select * from Contacts where ContactID=" + iDelContactID;
        DataTable DelContactInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);
        if (DelContactInfo.Rows.Count == 0)
        {
            PageCommon.WriteJsEnd(this, "Invalid contact id.", PageCommon.Js_RefreshParent);
        }

        #endregion

        if (this.IsPostBack == false)
        {
            #region 加载Service Type Filter

            ServiceTypes ServiceTypeManager = new ServiceTypes();
            DataTable    ServiceTypeList    = ServiceTypeManager.GetServiceTypeList(" and (Enabled=1)");
            DataRow      NewServiceTypeRow  = ServiceTypeList.NewRow();
            NewServiceTypeRow["ServiceTypeId"] = DBNull.Value;
            NewServiceTypeRow["Name"]          = "All";
            ServiceTypeList.Rows.InsertAt(NewServiceTypeRow, 0);
            ServiceTypeList.AcceptChanges();

            this.ddlServiceType.DataSource = ServiceTypeList;
            this.ddlServiceType.DataBind();

            #endregion

            if (this.Request.QueryString["DoSearch"] == null)
            {
                //this.divSearchCriteria.Visible = true;
                this.divSearchResult.Visible = false;
            }
            else
            {
                //this.divSearchCriteria.Visible = false;
                this.divSearchResult.Visible = true;

                #region 加载Contact List

                string sDbTable = "(select a.*, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as FullName, "
                                  + "'Partner' as ContactType, c.ServiceTypeID, e.Name as ServiceType, d.Name as BranchName, c.Name as CompanyName "
                                  + "from Contacts as a left outer join LoanContacts as b on a.ContactId = b.ContactId "
                                  + "left outer join ContactCompanies as c on a.ContactCompanyId = c.ContactCompanyId "
                                  + "left outer join ContactBranches as d on a.ContactBranchId=d.ContactBranchId "
                                  + "left outer join ServiceTypes as e on c.ServiceTypeId=e.ServiceTypeId "
                                  + "where b.ContactRoleId!=1 and b.ContactRoleId!=2 and a.ContactCompanyId is not null "
                                  + "union "
                                  + "select a.*, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as FullName, "
                                  + "'Client' as ContactType, null as ServiceTypeID, null as ServiceType, null as BranchName, null as CompanyName "
                                  + "from Contacts as a left outer join LoanContacts as b on a.ContactId = b.ContactId "
                                  + "where (b.ContactRoleId=1 or b.ContactRoleId=2)) as t";

                #region Build Where

                string sWhere = "";

                // ContactType
                if (this.Request.QueryString["ContactType"] != null)
                {
                    string sContactType = this.Request.QueryString["ContactType"].ToString();
                    if (sContactType == "Partner" || sContactType == "Client")
                    {
                        sWhere += " and ContactType='" + sContactType + "'";
                    }
                }

                // ServiceType
                if (this.Request.QueryString["ServiceType"] != null)
                {
                    string sServiceType = this.Request.QueryString["ServiceType"].ToString();
                    sWhere += " and ServiceTypeID=" + sServiceType;
                }

                // Company
                if (this.Request.QueryString["Company"] != null)
                {
                    string sCompany = this.Request.QueryString["Company"].ToString();
                    sWhere += " and CompanyName like '%" + sCompany + "%'";
                }

                // Branch
                if (this.Request.QueryString["Branch"] != null)
                {
                    string sBranch = this.Request.QueryString["Branch"].ToString();
                    sWhere += " and BranchName like '%" + sBranch + "%'";
                }

                // LastName
                if (this.Request.QueryString["LastName"] != null)
                {
                    string sLastName = this.Request.QueryString["LastName"].ToString();
                    sWhere += " and LastName like '" + sLastName + "%'";
                }

                // Address
                if (this.Request.QueryString["Address"] != null)
                {
                    string sAddress = this.Request.QueryString["Address"].ToString();
                    sWhere += " and MailingAddr like '" + sAddress + "%'";
                }

                // City
                if (this.Request.QueryString["City"] != null)
                {
                    string sCity = this.Request.QueryString["City"].ToString();
                    sWhere += " and MailingCity like '" + sCity + "%'";
                }

                // State
                if (this.Request.QueryString["State"] != null)
                {
                    string sState = this.Request.QueryString["State"].ToString();
                    sWhere += " and MailingState='" + sState + "'";
                }

                #endregion

                this.ContactSqlDataSource.ConnectionString = LPWeb.DAL.DbHelperSQL.connectionString;

                this.ContactSqlDataSource.SelectParameters["DbTable"].DefaultValue = sDbTable;

                int iRowCount = LPWeb.DAL.DbHelperSQL.Count(this.ContactSqlDataSource.SelectParameters["DbTable"].DefaultValue, sWhere);

                this.AspNetPager1.RecordCount = iRowCount;

                this.ContactSqlDataSource.SelectParameters["Where"].DefaultValue = sWhere;
                this.gridContactList.DataBind();

                #endregion
            }
        }
    }