using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Maticsoft.BLL; using System.Data; using System.Data.SqlClient; using Ajax; public partial class Wages_browse : CommonPage { //创建一个共用的编码bll层 Maticsoft.BLL.nr_sys_bianma bm = new Maticsoft.BLL.nr_sys_bianma(); //创建一个共用的类型BLL层 Maticsoft.BLL.nr_sys_leixing bmlx = new Maticsoft.BLL.nr_sys_leixing(); //创建一个共用的工价档案bll层 Maticsoft.BLL.nr_z_cpkc_gj gjdabll = new Maticsoft.BLL.nr_z_cpkc_gj(); //创建一个共用的工价档案 Maticsoft.Model.nr_z_cpkc_gj gjdamd = new Maticsoft.Model.nr_z_cpkc_gj(); //创建一个操作记录bll Maticsoft.BLL.nr_sys_rizhi rizhibll = new Maticsoft.BLL.nr_sys_rizhi(); //创建一个操作记录模板 Maticsoft.Model.nr_sys_rizhi rizhi = new Maticsoft.Model.nr_sys_rizhi(); protected void Page_Load(object sender, EventArgs e) { Utility.RegisterTypeForAjax(typeof(Wages_browse)); if (!IsPostBack) { if (Session["user"] == null) { Response.Redirect("../index.aspx"); } //获取角色权限 Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]); if (Request.QueryString["uid"] != null && Request.QueryString["uid"].ToString().Length > 0) { pdquanxianbj(user.juese); string uid = Request.QueryString["uid"].ToString(); id.Value = uid; initdata(uid); } else { pdquanxian(user.juese); } } } #region 修改时获取真正数据值 private void initdata(string did) { DataSet ds = DBHlper.Execute("select * from view_nr_z_cpkc_gj where id='" + did + "'"); if (ds != null && ds.Tables[0].Rows.Count > 0) { cpbh.Value = ds.Tables[0].Rows[0]["cpbh"].ToString(); cpmc.Value = ds.Tables[0].Rows[0]["cpmc"].ToString(); cpzl.Value = ds.Tables[0].Rows[0]["zl"].ToString(); guige.Value = ds.Tables[0].Rows[0]["gg"].ToString(); zhongliang.Value = ds.Tables[0].Rows[0]["zhongliang"].ToString(); tiji.Value = ds.Tables[0].Rows[0]["tiji"].ToString(); DataSet gjds = DBHlper.Execute(" select * from view_bianma where zhonglei='前段工价' or zhonglei='中段工价' or zhonglei='后段工价'"); if (gjds != null && gjds.Tables[0].Rows.Count > 0) { //修改页面时,首先吧项目明细的表头加载出来 string biao = " "; int x = 0; foreach (DataRow r in gjds.Tables[0].Rows) { if (x == 0) { biao += ""; } x = x + 1; string cpgjzhi = DBHlper.getfirstcolmn("select isnull(gjjg,0) from nr_z_cpkc_gj where cpid='" + did + "' and gjmc='" + r["mingcheng"] + "'"); biao += ""; if (x == 6) { biao += ""; x = 0; } } if (x > 0 && x < 6) { for (int c = 0; c < 6 - x; c++) { biao += ""; } biao += ""; } gjxx.InnerHtml = biao + "
" + r["mingcheng"] + "  
" + "  
"; } } } #endregion #region 获取页面参数赋值model对象 private void getmd() { //给日志模板赋值 rizhi.riqi = DateTime.Now; rizhi.leixing = "工价档案"; } #endregion #region 敏感权限查看 void pdquanxian(int juese) { Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]); if (DBHlper.getzt(user.id) != 1) { Response.Redirect("../index.aspx"); } if (DBHlper.GetPermission(juese, "工价档案", "nr_z_cpkc_gj", "添加") == false) { Response.Redirect("../Common/nopower.htm"); } } #endregion #region 编辑权限查看 void pdquanxianbj(int juese) { Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]); if (DBHlper.getzt(user.id) != 1) { Response.Redirect("../index.aspx"); } if (DBHlper.GetPermission(juese, "工价档案", "nr_z_cpkc_gj", "编辑全部") == false) { Response.Redirect("../Common/nopower.htm"); } } #endregion protected void bt_tj_Click(object sender, EventArgs e) { try { string caozuo = "添加"; getmd(); //接收成功参数值 int rtx = 0; //判断uid是否存在值,有值为修改,无值为添加 DBHlper.excutecmd("delete nr_z_cpkc_gj where cpid='" + id.Value + "'"); List gjdads = new List(); gjdads = DBHlper.ConvertJsonToEntityListEntity(gjxxhd.Value); foreach (Maticsoft.Model.nr_z_cpkc_gj gjx in gjdads) { gjx.cpid = Convert.ToInt32(id.Value); rtx = gjdabll.Add(gjx); } caozuo = "修改"; if (rtx > 0) { //将session转换对象取值 Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"]; //拼接字符串插入日志 rizhi.jilu = zh.zhanghao + caozuo + "了工价档案,档案编号为:" + cpbh.Value.Trim(); rizhi.yonghuming = zh.zhanghao; rizhibll.Add(rizhi); Response.Redirect("Wages_browse.aspx?uid=" + id.Value, false); } else { Response.Redirect("../Common/error.aspx"); } } catch (Exception) { Response.Redirect("../Common/error.aspx"); } } //查询客户名称是否重复 [Ajax.AjaxMethod()] public int serchmingcheng(string str) { string cmd = string.Format("select count(*) from nr_z_cpkc_gj where mingcheng='{0}'", str.Replace(" ", "")); int count = DBHlper.getcount(cmd); return count; } }