";
}
return htmlcode;
}
else
{
string lieselect = string.Format("select * from nr_sys_lieming where tblname='{0}' ORDER BY xh", "view_nr_z_cpkc_gj");
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_cpkc_gj", 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_cpkc_gj " + tj);
Maticsoft.Model.nr_z_yhzh yhzh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
if (!DBHlper.GetPermission(yhzh.juese, "工价档案", "view_nr_z_cpkc_gj", "查看全部"))
{
if (tj == "")
{
cmd += " where jsr='" + yhzh.zhanghao + "'";
}
else
{
cmd += " and jsr='" + 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[] pxzu = code.Split(';');
string[] codezu = new string[4];
foreach (string px in pxzu)
{
codezu = px.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_cpkc_gj", 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_cpkc_gj", 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_cpkc_gj", 1);
DataTable dtselect = DBHlper.Execute(paixuselct).Tables[0];
string htmlcode = "
";
foreach (DataRow dr in dtselect.Rows)
{
htmlcode += string.Format("
{1}
", dr["lieming"], dr["zhongwen"]);
}
DataSet gjds = DBHlper.Execute("select * from view_bianma where (zhonglei='前段工价' or zhonglei='中段工价' or zhonglei='后段工价') and zt='1'");
if (gjds != null & gjds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in gjds.Tables[0].Rows)
{
htmlcode += string.Format("
{1}
", dr["mingcheng"], dr["mingcheng"]);
}
}
return htmlcode;
}
#endregion
#region 获取隐藏的列
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public string yincanglie(int endid)
{
Maticsoft.Model.nr_z_yhzh zhanghao = (Maticsoft.Model.nr_z_yhzh)Session["user"];
endid = endid - 1;
string displaycmd = "select * from nr_lt_paixu where isxianshi=0 and tblname='view_nr_z_cpkc_gj' and userid='" + zhanghao.id + "'";
DataTable distable = DBHlper.Execute(displaycmd).Tables[0];
string htmlcode = "";
foreach (DataRow dr in distable.Rows)
{
endid++;
htmlcode += "
" + endid + "
" + dr["zhongwen"] + "
";
}
return htmlcode;
}
#endregion
#region 查询数据总数
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public int sumitem(string wheretj)
{
string selectcmd = "select count(*) from view_nr_z_cpkc_gj " + wheretj;
Maticsoft.Model.nr_z_yhzh yhzh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
if (!DBHlper.GetPermission(yhzh.juese, "工价档案", "view_nr_z_cpkc_gj", "查看全部"))
{
if (wheretj == "")
{
selectcmd += " where yewuyuan='" + yhzh.zhanghao + "'";
}
else
{
selectcmd += " and yewuyuan='" + yhzh.zhanghao + "'";
}
}
int sumcount = DBHlper.getcount(selectcmd);
return sumcount;
}
#endregion
#region 日期查询
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
public string nowdaycount(int selmonth)
{
DateTime nowdt = DateTime.Now;
int days = DateTime.DaysInMonth(nowdt.Year, selmonth);
string yuechu = nowdt.Year + "-" + selmonth + "-" + "1";
string yuemo = Convert.ToDateTime(nowdt.Year + "-" + selmonth + "-" + days).AddDays(1).ToString("yyyy-MM-dd");
DateTime yc = Convert.ToDateTime(yuechu);
string cmd = string.Format("select CONVERT(varchar(12),riqi,111) as 'riqi' from view_nr_z_cpkc_gj where riqi>='{0}' and riqi<='{1}'", yuechu, yuemo);
Maticsoft.Model.nr_z_yhzh yhzh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
DataTable dt = DBHlper.Execute(cmd).Tables[0];
var biao = "