⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemselectctrl.ascx.cs

📁 CRM管理系统 CRM管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Contact_Ctrls_ItemSelectCtrl : PageBaseUserCtrl
{
    private WYX.Dataport.Dataport dataport = new WYX.Dataport.Dataport();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SetData();
        }
    }

    #region 页面设置
    /// <summary>
    /// 初始化页面

    /// </summary>
    private void SetData()
    {
        BindTotalCount();
        BindItem();
    }

    /// <summary>
    /// 邦定项目
    /// </summary>
    private void BindItem()
    {
        pager.ShowCustomInfoSection = Wuqi.Webdiyer.ShowCustomInfoSection.Left;
        pager.ShowInputBox = Wuqi.Webdiyer.ShowInputBox.Always;
        pager.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
        pager.NumericButtonCount = 8;
        pager.AlwaysShow = true;
        pager.UrlPaging = false;
        pager.Wrap = false;
        pager.ShowPageIndex = false;
        pager.FirstPageText = "   首页   ";
        pager.PrevPageText = "   上一页   ";
        pager.NextPageText = "   下一页   ";
        pager.LastPageText = "   最后页   ";
        pager.PageSize = 24;

        pager.CustomInfoHTML = "记录总数:<font color=\"blue\"><b>" + pager.RecordCount.ToString() + "</b></font>";
        pager.CustomInfoHTML += " 总页数:<font color=\"blue\"><b>" + pager.PageCount.ToString() + "</b></font>";
        pager.CustomInfoHTML += " 当前页:<font color=\"red\"><b>" + pager.CurrentPageIndex.ToString() + "</b></font>";

        string sql = "SELECT * FROM dictionary where parent_id = 103";
        if (txtComName.Text.Trim().Replace("'", "\"").Length > 0)
        {
            sql += " and dict_name like '%" + txtComName.Text.Trim().Replace("'", "\"") + "%'";
        }
        sql += " order by dict_name";
        SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"].ToString());
        SqlDataAdapter PropList = new SqlDataAdapter(sql, conn);
        DataSet ds = new DataSet();
        try
        {
            PropList.Fill(ds, pager.PageSize * (pager.CurrentPageIndex - 1), pager.PageSize, "PropList");
            dtlItem.DataSource = ds.Tables["PropList"];
            dtlItem.DataKeyField = ds.Tables["PropList"].Columns["dict_id"].ToString();
            dtlItem.DataBind();
        }
        catch (Exception)
        {
            PropList.Fill(ds, pager.PageSize * (pager.CurrentPageIndex - 1), pager.PageSize, "PropList");
            dtlItem.DataSource = ds.Tables["PropList"];
            dtlItem.DataBind();
        }
    }
    /// <summary>
    /// 绑定记录数
    /// </summary>
    private void BindTotalCount()
    {
        string strCount = null;
        strCount = "SELECT count(*) FROM dictionary where parent_id = 103";
        if (txtComName.Text.Trim().Replace("'", "\"").Length > 0)
        {
            strCount += " and dict_name like '%" + txtComName.Text.Trim().Replace("'", "\"") + "%'";
        }
        try
        {
            DataRow dr = dataport.GetRowResult(strCount);
            int TotalCount = Convert.ToInt32(dr[0].ToString());
            pager.RecordCount = TotalCount;
        }
        catch (Exception)
        {
            DataRow dr = dataport.GetRowResult(strCount);
            int TotalCount = Convert.ToInt32(dr[0].ToString());
            pager.RecordCount = TotalCount;
        }
    }
    #endregion
    /// <summary>
    /// 查询
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSelect_Click(object sender, EventArgs e)
    {
        BindTotalCount();
        BindItem();
    }
    /// <summary>
    /// 条件清空
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnClear_Click(object sender, EventArgs e)
    {
        txtComName.Text = "";
        BindTotalCount();
        BindItem();
    }
    protected void pager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        pager.CurrentPageIndex = e.NewPageIndex;
        BindTotalCount();
        BindItem();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -