268 lines
9.8 KiB
C#
268 lines
9.8 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using System.Data;
|
||
using Ajax;
|
||
|
||
public partial class OutsourcingContract_browse : System.Web.UI.Page
|
||
{
|
||
Maticsoft.Model.nr_z_ddwxd wxdmodel = new Maticsoft.Model.nr_z_ddwxd();
|
||
Maticsoft.BLL.nr_z_ddwxd wxdbll = new Maticsoft.BLL.nr_z_ddwxd();
|
||
Maticsoft.BLL.nr_z_dd ddbll = new Maticsoft.BLL.nr_z_dd();
|
||
Maticsoft.Model.nr_z_dd ddmodel = new Maticsoft.Model.nr_z_dd();
|
||
Maticsoft.BLL.nr_z_waixie wxbll = new Maticsoft.BLL.nr_z_waixie();
|
||
Maticsoft.Model.nr_z_waixie wxmodel = new Maticsoft.Model.nr_z_waixie();
|
||
Maticsoft.BLL.nr_z_kehu kehubll = new Maticsoft.BLL.nr_z_kehu();
|
||
//创建一个操作记录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)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
|
||
if (Session["user"] == null)
|
||
{
|
||
Response.Redirect("../index.aspx");
|
||
}
|
||
Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]);
|
||
Utility.RegisterTypeForAjax(typeof(OutsourcingContract_browse));
|
||
if (Request.QueryString["uid"] != null && Request.QueryString["uid"] != "")
|
||
{
|
||
id.Value = Request.QueryString["uid"].ToString();
|
||
}
|
||
else
|
||
{
|
||
Response.Redirect("../Common/error.aspx");
|
||
}
|
||
initdata(id.Value);
|
||
setwxxm(id.Value);
|
||
pdquanxian(user.juese);
|
||
upddfy(Convert.ToInt32(id.Value));
|
||
}
|
||
|
||
}
|
||
|
||
#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, "外协单", "view_nr_z_ddwxd", "查看全部") == false && DBHlper.GetPermission(juese, "外协单", "view_nr_z_ddwxd", "查看个人") == false)
|
||
{
|
||
Response.Redirect("../Common/nopower.htm");
|
||
}
|
||
|
||
if (DBHlper.GetPermission(juese, "外协单", "view_nr_z_ddwxd", "编辑个人") && kdr.Text == user.zhanghao)
|
||
{
|
||
bt_bj.Visible = true;
|
||
|
||
}
|
||
if (DBHlper.GetPermission(juese, "外协单", "view_nr_z_ddwxd", "编辑全部"))
|
||
{
|
||
bt_bj.Visible = true;
|
||
|
||
}
|
||
if (DBHlper.GetPermission(juese, "外协单", "view_nr_z_ddwxd", "删除个人") && kdr.Text == user.zhanghao)
|
||
{
|
||
shanchu.Visible = true;
|
||
}
|
||
if (DBHlper.GetPermission(juese, "外协单", "view_nr_z_ddwxd", "删除全部"))
|
||
{
|
||
shanchu.Visible = true;
|
||
|
||
}
|
||
|
||
|
||
if (DBHlper.GetPermission(juese, "外协单", "view_nr_z_ddwxd", "审核"))
|
||
{
|
||
shenhetg.Visible = true;
|
||
shenhebg.Visible = true;
|
||
}
|
||
if (zt.Text == "通过")
|
||
{
|
||
shenhetg.Enabled = false;
|
||
shenhetg.BackColor = System.Drawing.Color.Gray;
|
||
shanchu.Enabled = false;
|
||
shanchu.BackColor = System.Drawing.Color.Gray;
|
||
bt_bj.Enabled = false;
|
||
bt_bj.BackColor = System.Drawing.Color.Gray;
|
||
}
|
||
if (zt.Text == "不过")
|
||
{
|
||
shenhebg.Enabled = false;
|
||
shenhebg.BackColor = System.Drawing.Color.Gray;
|
||
}
|
||
|
||
if (DBHlper.GetPermission(juese, "外协单", "view_nr_z_ddwxd", "回收"))
|
||
{
|
||
//bt_hs.Visible = true;
|
||
}
|
||
if (DBHlper.GetPermission(juese, "外协单", "view_nr_z_ddwxd", "打印"))
|
||
{
|
||
dayin.Visible = true;
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 获取真正数据值
|
||
private void initdata(string did)
|
||
{
|
||
int idz = Convert.ToInt32(did);
|
||
wxdmodel = wxdbll.GetModel(idz);
|
||
wxmodel = wxbll.GetModel(Convert.ToInt32(wxdmodel.wxid));
|
||
wxdh.Text = wxdmodel.wxdh;
|
||
lxr.Text = wxdmodel.lianxiren;
|
||
lxfs.Text = wxdmodel.lxfs;
|
||
fdrq.Text = Convert.ToDateTime(wxdmodel.fdrq).ToString("yyyy-MM-dd").ToString();
|
||
zt.Text = wxdmodel.zt.ToString();
|
||
kdr.Text = wxdmodel.kdr.ToString();
|
||
shr.Text = wxdmodel.shr.ToString();
|
||
zlyq.Text = wxdmodel.zlyq;
|
||
bz.Text = wxdmodel.bz;
|
||
wxfyze.Text = DBHlper.getfirstcolmn("select wxfyze from view_nr_z_ddwxd where id='" + did + "'");
|
||
|
||
}
|
||
#endregion
|
||
#region 修改时添加项目
|
||
private void setwxxm(string wxid)
|
||
{
|
||
|
||
//修改页面时,首先吧项目明细的表头加载出来
|
||
string biao = "<table class='bule'> <tr class='tbtilt' >"
|
||
+ "<td><span>生产编号</span></td><td><span>客户编号</span></td><td><span>产品货号</span></td>"
|
||
+ "<td><span>产品名称</span></td><td><span>种类</span></td><td><span>特殊工艺</span></td> "
|
||
+ "<td><span>外发数量</span></td><td><span>交货日期</span></td>"
|
||
+ "<td><span>备注</span></td></tr>";
|
||
DataSet xmds = DBHlper.Execute("select * from dbo.nr_z_ddwxd_xm where wxid='" + wxid + "'");
|
||
foreach (DataRow r in xmds.Tables[0].Rows)
|
||
{
|
||
//为保证唯一性,获取id拼接,保证稳定性
|
||
string hcount = r["id"].ToString();
|
||
biao += "<tr id='" + hcount + "' name='" + hcount + "'> "
|
||
+ "<td><span>" + r["scdh"] + "</span></td>"
|
||
+ "<td><span>" + r["khbh"] + "</span></td>"
|
||
+ "<td><span>" + r["cphh"] + "</span></td>"
|
||
+ "<td><span>" + r["cpmc"] + "</span></td>"
|
||
+ "<td><span>" + r["cpzl"] + "</span></td>"
|
||
+ "<td><span>" + r["scfs"] + "</span></td>"
|
||
+ "<td><span>" + r["wfsl"] + "</span></td>"
|
||
+ "<td><span>" + Convert.ToDateTime(r["jhrq"]).ToString("yyyy-MM-dd") + "</span></td>"
|
||
+ "<td><span>" + r["bz"] + "</span></td></tr>";
|
||
|
||
}
|
||
cpxx.InnerHtml = biao + "</table>";
|
||
}
|
||
#endregion
|
||
protected void shanchu_Click(object o, EventArgs e)
|
||
{
|
||
|
||
bool isdelete = wxdbll.Delete(Convert.ToInt32(id.Value));
|
||
if (isdelete)
|
||
{
|
||
//给日志模板赋值
|
||
rizhi.riqi = DateTime.Now;
|
||
rizhi.leixing = "外协单";
|
||
//将session转换对象取值
|
||
Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
||
//拼接字符串插入日志
|
||
rizhi.jilu = zh.zhanghao + "删除了外协单,外协单号为:" + wxdh.Text.Trim();
|
||
rizhi.yonghuming = zh.zhanghao.ToString();
|
||
rizhi.riqi = DateTime.Now;
|
||
rizhi.leixing = "外协单";
|
||
rizhibll.Add(rizhi);
|
||
Response.Redirect("OutsourcingContract_list.aspx", false);
|
||
}
|
||
else
|
||
{
|
||
Response.Write("<script>alert('删除失败')</script>");
|
||
}
|
||
|
||
}
|
||
protected void shenhetg_Click(object o, EventArgs e)
|
||
{
|
||
//将session转换对象取值
|
||
Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
||
wxdmodel = wxdbll.GetModel(Convert.ToInt32(id.Value));
|
||
wxdmodel.zt = "通过";
|
||
wxdmodel.shr = zh.zhanghao;
|
||
wxdbll.Update(wxdmodel);
|
||
rizhi.riqi = DateTime.Now;
|
||
rizhi.leixing = "外协单";
|
||
//拼接字符串插入日志
|
||
rizhi.jilu = zh.zhanghao + "执行审核通过,外协单号为:" + wxdh.Text.Trim();
|
||
rizhi.yonghuming = zh.zhanghao.ToString();
|
||
rizhibll.Add(rizhi);
|
||
Response.Redirect("OutsourcingContract_browse.aspx?uid=" + id.Value);
|
||
}
|
||
protected void shenhebg_Click(object o, EventArgs e)
|
||
{
|
||
Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
||
wxdmodel = wxdbll.GetModel(Convert.ToInt32(id.Value));
|
||
wxdmodel.zt = "不过";
|
||
wxdmodel.shr = zh.zhanghao;
|
||
wxdbll.Update(wxdmodel);
|
||
|
||
//拼接字符串插入日志
|
||
rizhi.jilu = zh.zhanghao + "执行审核不过,外协单号为:" + wxdh.Text.Trim();
|
||
rizhi.yonghuming = zh.zhanghao.ToString();
|
||
rizhi.riqi = DateTime.Now;
|
||
rizhi.leixing = "外协单";
|
||
rizhibll.Add(rizhi);
|
||
Response.Redirect("OutsourcingContract_browse.aspx?uid=" + id.Value);
|
||
}
|
||
protected void bj_Click(object o, EventArgs e)
|
||
{
|
||
Response.Redirect("OutsourcingContract_Form.aspx?uid=" + id.Value);
|
||
}
|
||
#region 用来加载编辑外协单费用
|
||
private void upddfy(int wxdid)
|
||
{
|
||
|
||
DataSet ds = DBHlper.Execute("select * from view_bianma where zhonglei='外协费用'");
|
||
|
||
string biao = "<table class='bule'><tr> ";
|
||
int ci = 0;
|
||
if (ds != null && ds.Tables[0].Rows.Count > 0)
|
||
{
|
||
foreach (DataRow i in ds.Tables[0].Rows)
|
||
{
|
||
|
||
DataSet fyds = DBHlper.Execute("select fyje from nr_z_ddwxd_fy where wxdid='" + wxdid + "' and fymc='" + i["mingcheng"] + "'");
|
||
ci = ci + 1;
|
||
if (fyds != null && fyds.Tables[0].Rows.Count > 0)
|
||
{
|
||
biao += "<td><span>" + i["mingcheng"] + ":" + Convert.ToDouble(fyds.Tables[0].Rows[0]["fyje"]) + "</span></td>";
|
||
}
|
||
else
|
||
{
|
||
biao += "<td><span>" + i["mingcheng"] + ":0 </span></td>";
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
fyxx.InnerHtml = biao + "</tr></table> ";
|
||
|
||
}
|
||
#endregion
|
||
|
||
|
||
#region 回收数量
|
||
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
||
public int uphssl(int id, double hssl)
|
||
{
|
||
return DBHlper.excutecmd("update nr_z_ddwxd set hssl=" + hssl + " where id=" + id + "");
|
||
|
||
}
|
||
#endregion
|
||
|
||
} |