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

📄 customermanage.ascx.cs

📁 CRM管理系统 CRM管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
        }   
        sqlWhere = sbWhere.ToString();
        return sqlWhere;
    }
    #region 分页取数据 GetDataSet
    /// <summary>
    /// 功    能:分页
    /// 作    者:鼠标王

    /// 完成时间:2007-06-21
    /// 版    权:940208@qq.com
    /// </summary>
    /// <param name="tblName">表名</param>
    /// <param name="fldName">主键字段名</param>
    /// <param name="PageSize">页尺寸</param>
    /// <param name="PageIndex">页码</param>
    /// <param name="IsReCount">返回记录总数, 非 0 值则返回</param>
    /// <param name="OrderType">设置排序类型, 非 0 值则降序</param>
    /// <param name="strWhere">查询条件 (注意: 不要加 where)</param>
    /// <returns>ds</returns>
    public DataSet Minutepage(string tblName, string fldName, int PageSize, int PageIndex, int IsReCount, int OrderType, string strWhere)
    {
        //string sql = "exec UP_GetRecordByPage " + tblName + "," + fldName + "," + PageSize + "," + PageIndex + "," + IsReCount + "," + OrderType + ",\"'" + strWhere + "'\" ";
        string sql = "exec UP_GetRecordByPage '" + tblName + "','" + fldName + "'," + PageSize + "," + PageIndex + "," + IsReCount + "," + OrderType + ",'" + strWhere + "' ";
        DataSet ds = dataport.GetDataSet(sql);
        return ds;
    }

    /// <summary>
    /// 绑定分页
    /// </summary>
    private void BindPager()
    {
        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.SubmitButtonText = "跳转";
        pager.PageSize = PageSize;

        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>";
    }
    #endregion
    /// <summary>
    /// 查询
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ntnSelect_Click(object sender, EventArgs e)
    {
        strWhere = condition();
        GridView1.PageIndex = 0;
        pager.CurrentPageIndex = 1;
        BindGridView();
    }
    /// <summary>
    /// 清空查询条件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnClear_Click(object sender, EventArgs e)
    {
        strWhere = null;
        if (GetSystemRole(this.CurrentUser.account) || !_isShow)
        {
            strWhere = " 1=1 and is_delete = 0";
        }
        else
        {
            strWhere = " 1=1 and is_delete = 0 and tracking_persen  = ''" + this.CurrentUser.user_id + "''";
        }
        this.ddlTrack.SelectedIndex = 0;
        this.txtComName.Text = "";
        this.ddlRelation.SelectedIndex = 0;
        this.ddlComType.SelectedIndex = 0;

        GridView1.PageIndex = 0;
        pager.CurrentPageIndex = 1;
        BindGridView();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        strWhere = condition();
        BindGridView();
    }
    protected void pager_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        pager.CurrentPageIndex = e.NewPageIndex;
        GridView1.PageIndex = e.NewPageIndex - 1;
        strWhere = condition();
        BindGridView();
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //当鼠标停留时更改背景色


            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#ededFF'");
            //当鼠标移开时还原背景色
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

            int rowIndex = e.Row.RowIndex;
            LinkButton lbtnEdit = (LinkButton)(e.Row.FindControl("lbtnEdit"));
            LinkButton lbtnDelete = (LinkButton)(e.Row.FindControl("lbtnDelete"));
            LinkButton lbtnCode = (LinkButton)(e.Row.FindControl("lbtnCode"));
            LinkButton lbtnName = (LinkButton)(e.Row.FindControl("lbtnName"));
            LinkButton lbtnPersen = (LinkButton)(e.Row.FindControl("lbtnPersen"));
            Label Label1 = (Label)(e.Row.FindControl("Label1"));
            Label Label2 = (Label)(e.Row.FindControl("Label2"));
            Label lblPersonSum = (Label)(e.Row.FindControl("lblPersonSum"));
            lbtnDelete.Attributes.Add("onclick", "return confirm('确实要删除本条信息吗?')");

            try
            {
                //主键
                int code = Convert.ToInt32(GridView1.DataKeys[e.Row.RowIndex].Value.ToString());
            }
            catch (Exception)
            {
                lbtnEdit.Visible = false;
                lbtnDelete.Visible = false;
                lbtnCode.Visible = false;
                lbtnName.Visible = false;
                lbtnPersen.Visible = false;
                Label1.Visible = false;
                Label2.Visible = false;
                lblPersonSum.Visible = false;
            }
            if (lbtnEdit != null && lbtnEdit.Visible)
            {
                lbtnEdit.CommandArgument = rowIndex.ToString();
            }

            if (lbtnDelete != null && lbtnDelete.Visible)
            {
                lbtnDelete.CommandArgument = rowIndex.ToString();
            }

            if (lbtnCode != null && lbtnCode.Visible)
            {
                lbtnCode.CommandArgument = rowIndex.ToString();
            }
            if (lbtnName != null && lbtnName.Visible)
            {
                lbtnName.CommandArgument = rowIndex.ToString();
            }
            if (lbtnPersen != null && lbtnPersen.Visible)
            {
                lbtnPersen.CommandArgument = rowIndex.ToString();
            }
            if (lblPersonSum != null && lblPersonSum.Visible)
            {
                int code = Convert.ToInt32(GridView1.DataKeys[e.Row.RowIndex].Value.ToString());
                String sql = " SELECT count(*) FROM ITSV_customer_person where customer_id = " + code + " ";
                try
                {
                    lblPersonSum.Text = "(" +dataport.GetRowResultID(sql)+")";
                }
                catch
                {
                    lblPersonSum.Text = "(0)";
                }
            }
        }
    }
    /// <summary>
    /// 增加
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect("CustomerAdd.aspx");
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string url = Request.RawUrl;
        if (e.CommandName == "lbtnName" || e.CommandName == "lbtnCode")
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument.ToString());
            int code = Convert.ToInt32(GridView1.DataKeys[rowIndex].Value.ToString());
            Response.Redirect("CustomerLook.aspx?url="+Server.UrlEncode(url)+"&code=" + code);
        }
        if (e.CommandName == "lbtnPersen")
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument.ToString());
            int code = Convert.ToInt32(GridView1.DataKeys[rowIndex].Value.ToString());
            Response.Redirect("PersenManage.aspx?code=" + code);
        }
        if (e.CommandName == "lbtnEdit")
        {
            int rowIndex = Convert.ToInt32(e.CommandArgument.ToString());
            int code = Convert.ToInt32(GridView1.DataKeys[rowIndex].Value.ToString());
            Response.Redirect("CustomerEdit.aspx?code=" + code);
        }
        if (e.CommandName == "lbtnDelete")
        {
            string name = null;
            int rowIndex = Convert.ToInt32(e.CommandArgument.ToString());
            int code = Convert.ToInt32(GridView1.DataKeys[rowIndex].Value.ToString());
            string sql = "Update ITSV_CustomerManager set is_delete = 1 where code= " + code + "";
            bool falg = dataport.ExeSql(sql);
            String sqlname = "select name from ITSV_CustomerManager where code = " + code;
            try
            {
                name = dataport.GetRowResultID(sqlname);
            }
            catch
            {
                name = "";
            }
            if (!falg)
            {
                ShowMessage("数据删除失败!");
            }
            else
            {
                this.WriteUserAction("删除客户\"" + name + "\"的信息");
            }
            Response.Redirect("CustomerManage.aspx");
        }
    }
    /// <summary>
    /// 到出导Excel
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnCsv_Click(object sender, EventArgs e)
    {
        strWhere = condition();
        string sql = "SELECT * FROM ITSV_CustomerManager where " + strWhere.Replace("''", "'");
        
        DataSet ds = null;
        try
        {
            ds = dataport.GetDataSet(sql);
        }
        catch
        {
            ds = null;
        }
        if (ds == null)
        {
            this.ShowMessage(msg);
            return;
        }
        if (ds.Tables[0].Rows.Count > 0)
        {
            DataTable dt = ds.Tables[0];
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            sb.Append("<table cellspacing=\"0\" cellpadding=\"3\" rules=\"all\" border=\"1\" style=\"border-color:#E7E7FF;border-width:1px;border-style:None;width:100%;border-collapse:collapse;\">");
            sb.Append("<tr align=\"center\" style=\"color:#F7F7F7;background-color:#4A3C8C;font-weight:bold;height:18px;\">\r\n");
            sb.Append("     <th scope=\"col\" style=\"width:10%;\">客户编号</th>\r\n");
            sb.Append("     <th scope=\"col\" style=\"width:30%;\">客户名称</th>\r\n");
            sb.Append("     <th scope=\"col\" style=\"width:10%;\">关系程度</th>\r\n");
            sb.Append("     <th scope=\"col\" style=\"width:10%;\">销售人员</th>\r\n");
            sb.Append("     <th scope=\"col\" style=\"width:10%;\">客户类型</th>\r\n");
            sb.Append("     <th scope=\"col\" style=\"width:15%;\">公司电话</th>\r\n");
            sb.Append("     <th scope=\"col\" style=\"width:15%;\">邮件地址</th>\r\n");
            sb.Append("</tr>");
            foreach (DataRow dr in dt.Rows)
            {
                sb.Append("<tr style=\"font-size:12px;\">");

                sb.Append("     <td style=\"vnd.ms-excel.numberformat:@\">" + dr["code"].ToString() + "</td>");
                sb.Append("     <td>" + dr["name"].ToString() + "</td>");

                Itsv.Model.dictionary dict = GetDictionaryMonel(dr["relation"].ToString());
                if (dict != null)
                {
                    sb.Append("     <td>" + GetDictionaryMonel(dr["relation"].ToString()).dict_name + "</td>");
                }
                else
                {
                    sb.Append("     <td>" + dr["relation"].ToString() + "</td>");
                }
                sb.Append("     <td>" + GetUser(dr["tracking_persen"].ToString()) + "</td>");
                dict = GetDictionaryMonel(dr["type"].ToString());
                if (dict != null)
                {
                    sb.Append("     <td>" + GetDictionaryMonel(dr["type"].ToString()).dict_name + "</td>");
                }
                else
                {
                    sb.Append("     <td>" + dr["type"].ToString() + "</td>");
                }
                sb.Append("     <td>" + dr["tel"].ToString() + "</td>");
                sb.Append("     <td>" + dr["email"].ToString() + "</td>");
                sb.Append("</tr>");
            }
            sb.Append("</table>");

            Response.ContentType = "application/vnd.ms-excel";

            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=ITSV_CustomerManager.xls");

            Response.Charset = "GB2312";

            //经测试如果设置为 GetEncoding("GB2312"),导出的文件将会出现乱码。


            Response.ContentEncoding = System.Text.Encoding.UTF7;
            System.IO.StringWriter sw = new System.IO.StringWriter();
            sw.Write(sb.ToString());
            Response.Write(sw.ToString());
            Response.End();
        }
        else
        {
            ShowMessage("对不起,没有符合条件的数据,请您重试!");
        }
    }
}

⌨️ 快捷键说明

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