251 lines
10 KiB
C#
251 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Ajax;
|
|
using System.Data;
|
|
public partial class ddselect_kehu_list : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
if (Session["user"] == null)
|
|
{
|
|
Response.Redirect("../index.aspx");
|
|
}
|
|
|
|
}
|
|
Utility.RegisterTypeForAjax(typeof(ddselect_kehu_list));
|
|
Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]);
|
|
hiddenid.Value = user.juese.ToString();
|
|
Hiddenname.Value = user.zhanghao;
|
|
pdquanxian(user.juese);
|
|
}
|
|
#region 数据加载输出
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public string page_change(int pg, int pageitem, string paixu, string tiaojian)
|
|
{
|
|
Maticsoft.Model.nr_z_yhzh zhanghao = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
string htmlcode = "";
|
|
string isexits = string.Format("select count(*) from nr_lt_paixu where userid='{0}' and tblname='{1}'", zhanghao.id, "view_nr_z_kehu");
|
|
int exitscount = DBHlper.getcount(isexits);
|
|
|
|
if (exitscount > 0)
|
|
{
|
|
string paixuselct = string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ", zhanghao.id, "view_nr_z_kehu", 1);
|
|
DataTable dtselect = DBHlper.Execute(paixuselct).Tables[0];
|
|
string wherecode = string.Format("select top {0} ", pageitem);
|
|
foreach (DataRow dtr in dtselect.Rows)
|
|
{
|
|
wherecode += dtr["lieming"] + ",";
|
|
}
|
|
wherecode += "id";
|
|
if (DBHlper.GetPermission(zhanghao.juese, "客户档案", "nr_z_kehu", "查看全部"))
|
|
{
|
|
wherecode += string.Format(" from view_nr_z_kehu where " + tiaojian + " id not in(select top ({0}*{1}) id from view_nr_z_kehu)" + paixu, pg, pageitem);
|
|
|
|
}
|
|
else if (DBHlper.GetPermission(zhanghao.juese, "客户档案", "nr_z_kehu", "查看个人"))
|
|
{
|
|
wherecode += string.Format(" from view_nr_z_kehu where yewuyuan='" + zhanghao.zhanghao + "' and " + tiaojian + " id not in(select top ({0}*{1}) id from view_nr_z_kehu)" + paixu, pg, pageitem);
|
|
|
|
}
|
|
DataTable dt_paixu = DBHlper.Execute(wherecode).Tables[0];
|
|
if (dt_paixu.Rows.Count == 0)
|
|
{
|
|
return "<tr><td>   没有数据</td></tr>";
|
|
}
|
|
|
|
for (int i = 0; i < dt_paixu.Rows.Count; i++)
|
|
{
|
|
htmlcode += "<tr ondblclick='check(" + dt_paixu.Rows[i]["id"] + ")' onclick='select(this)' tag='" + dt_paixu.Rows[i]["id"] + "' >";
|
|
htmlcode += " <td style='width:20px'><img class='xz' src='../Images_Folder/checkOff1.png' onclick='check(" + dt_paixu.Rows[i]["id"] + ")'></td>";
|
|
for (int j = 0; j < dt_paixu.Columns.Count - 1; j++)
|
|
{
|
|
if (dt_paixu.Columns[j].ColumnName == "zhaopian")
|
|
{
|
|
htmlcode += "<td><span style='cursor:pointer;'><img height='70' width=80 src=../Client_Folder/" + dt_paixu.Rows[i]["zhaopian"] + "/></span></td>";
|
|
}
|
|
else if (dt_paixu.Columns[j].ColumnName == "mingpian")
|
|
{
|
|
htmlcode += "<td><span style='cursor:pointer;'><img height='70' width=80 src=../Client_Folder/" + dt_paixu.Rows[i]["mingpian"] + "/></span></td>";
|
|
}
|
|
else
|
|
{
|
|
htmlcode += "<td>" + dt_paixu.Rows[i][j] + "</td>";
|
|
}
|
|
}
|
|
htmlcode += "</tr>";
|
|
}
|
|
return htmlcode;
|
|
}
|
|
else
|
|
{
|
|
string lieselect = string.Format("select * from nr_sys_lieming where tblname='{0}' ORDER BY xh", "view_nr_z_kehu");
|
|
DataTable liedt = DBHlper.Execute(lieselect).Tables[0];
|
|
int lieshuixu = 0;
|
|
foreach (DataRow liedr in liedt.Rows)
|
|
{
|
|
lieshuixu++;
|
|
string cmdinsert = string.Format("insert into nr_lt_paixu values('{0}','{1}','{2}','{3}',{4},{5})", zhanghao.id, "view_nr_z_kehu", liedr["ywlieming"], liedr["zwlieming"], lieshuixu, 1);
|
|
DBHlper.excutecmd(cmdinsert);
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
#endregion
|
|
#region 传入条数返回页数以便前台调用
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public int maxpage(int count, string tj)
|
|
{
|
|
int fanhuizhi = 0;
|
|
string cmd = string.Format("select count(*) from view_nr_z_kehu " + tj);
|
|
Maticsoft.Model.nr_z_yhzh yhzh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
if (!DBHlper.GetPermission(yhzh.juese, "客户档案", "nr_z_kehu", "查看全部"))
|
|
{
|
|
if (tj == "")
|
|
{
|
|
cmd += " where yewuyuan='" + yhzh.zhanghao + "'";
|
|
}
|
|
else
|
|
{
|
|
cmd += " and yewuyuan='" + yhzh.zhanghao + "'";
|
|
}
|
|
}
|
|
int sumcount = DBHlper.getcount(cmd);
|
|
if (sumcount > count)
|
|
{
|
|
fanhuizhi = sumcount / count;
|
|
}
|
|
return fanhuizhi;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 数据排序
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public void itempaixu(string code)
|
|
{
|
|
Maticsoft.Model.nr_z_yhzh yhzh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
string[] codezu = code.Split(',');
|
|
string cmdexits = string.Format("select id from nr_lt_paixu where userid='{0}' and tblname='{1}' and lieming='{2}'", yhzh.id, "view_nr_z_kehu", codezu[2]);
|
|
DataTable paixutable = DBHlper.Execute(cmdexits).Tables[0];
|
|
if (paixutable.Rows.Count > 0)
|
|
{
|
|
int idfanhui = Convert.ToInt32(paixutable.Rows[0][0]);
|
|
string updatepaixu = string.Format("update nr_lt_paixu set shuixu={0},isxianshi={1} where id={2}", codezu[0], codezu[3], idfanhui);
|
|
DBHlper.excutecmd(updatepaixu);
|
|
|
|
}
|
|
else
|
|
{
|
|
string paixuinsert = string.Format("insert into nr_paixu (userid,tblname,lieming,zhongwen,shuixu,isxianshi) values('{0}','{1}','{2}','{3}',{4},{5})", yhzh.id, "view_nr_z_kehu", codezu[2], codezu[1], codezu[0], codezu[3]);
|
|
DBHlper.excutecmd(paixuinsert);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 列头排序
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public string paixu()
|
|
{
|
|
Maticsoft.Model.nr_z_yhzh zhanghao = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
string paixuselct = string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ", zhanghao.id, "view_nr_z_kehu", 1);
|
|
DataTable dtselect = DBHlper.Execute(paixuselct).Tables[0];
|
|
string htmlcode = "<td style='width:20px'></td>";
|
|
foreach (DataRow dr in dtselect.Rows)
|
|
{
|
|
htmlcode += string.Format("<td tag='{0}'>{1}</td>", dr["lieming"], dr["zhongwen"]);
|
|
}
|
|
return htmlcode;
|
|
}
|
|
#endregion
|
|
|
|
#region 查询数据总数
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public int sumitem(string wheretj)
|
|
{
|
|
string selectcmd = "select count(*) from view_nr_z_kehu " + wheretj;
|
|
Maticsoft.Model.nr_z_yhzh yhzh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
if (!DBHlper.GetPermission(yhzh.juese, "客户档案", "nr_z_kehu", "查看全部"))
|
|
{
|
|
if (wheretj == "")
|
|
{
|
|
selectcmd += " where yewuyuan='" + yhzh.zhanghao + "'";
|
|
}
|
|
else
|
|
{
|
|
selectcmd += " and yewuyuan='" + yhzh.zhanghao + "'";
|
|
}
|
|
}
|
|
int sumcount = DBHlper.getcount(selectcmd);
|
|
return sumcount;
|
|
}
|
|
#endregion
|
|
#region 判断查看权限
|
|
[Ajax.AjaxMethod]
|
|
public string isquanxian(int uid)
|
|
{
|
|
|
|
if (DBHlper.GetPermission(uid, "客户档案", "nr_z_kehu", "查看全部"))
|
|
{
|
|
return "1";
|
|
}
|
|
else if (DBHlper.GetPermission(uid, "客户档案", "nr_z_kehu", "查看个人"))
|
|
{
|
|
return "0";
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
#endregion
|
|
#region 敏感权限查看
|
|
void pdquanxian(int juese)
|
|
{
|
|
Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]);
|
|
if (DBHlper.getzt(user.id) == 0)
|
|
{
|
|
Response.Redirect("../index.aspx");
|
|
}
|
|
if (!DBHlper.GetPermission(juese, "客户档案", "nr_z_kehu", "查看全部") && !DBHlper.GetPermission(juese, "客户档案", "nr_z_kehu", "查看个人"))
|
|
{
|
|
Response.Redirect("../Common/nopower.htm");
|
|
}
|
|
if (DBHlper.GetPermission(juese, "客户档案", "nr_z_kehu", "添加"))
|
|
{
|
|
li_add.Visible = true;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
[Ajax.AjaxMethod]
|
|
public string kehuxinxi(int id)
|
|
{
|
|
DataTable tbl_kehu = DBHlper.Execute("select bianhao,mingcheng,yewuyuan,dizhi,csqk from nr_z_kehu where id=" + id).Tables[0];
|
|
string fanhuicode = "";
|
|
fanhuicode += tbl_kehu.Rows[0]["bianhao"].ToString() + "//" + tbl_kehu.Rows[0]["mingcheng"].ToString() + "//" + tbl_kehu.Rows[0]["yewuyuan"].ToString() + "//";
|
|
DataTable tbl_lianxiren = DBHlper.Execute("select id,lianxiren,shouji from nr_z_lianxiren_kh where kh_bh='" + tbl_kehu.Rows[0]["bianhao"] + "'").Tables[0];
|
|
foreach (DataRow dr in tbl_lianxiren.Rows)
|
|
{
|
|
fanhuicode += "<option value='" + dr["id"].ToString() + "' tag='" + dr["shouji"] + "'>" + dr["lianxiren"].ToString() + "</option>";
|
|
}
|
|
if (tbl_lianxiren.Rows.Count > 0)
|
|
{
|
|
fanhuicode += "//" + tbl_lianxiren.Rows[0]["shouji"]+"//";
|
|
}
|
|
else {
|
|
fanhuicode += "////";
|
|
}
|
|
fanhuicode += tbl_kehu.Rows[0]["dizhi"] + "//" + tbl_kehu.Rows[0]["csqk"];
|
|
return fanhuicode;
|
|
|
|
}
|
|
|
|
|
|
} |