CeramicProject/newyt/Module_data/OutsourcingContract_Form.as...

350 lines
14 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class OutsourcingContract_Form : 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.Model.nr_z_waixie wxmodel = new Maticsoft.Model.nr_z_waixie();
Maticsoft.BLL.nr_z_waixie wxbll = new Maticsoft.BLL.nr_z_waixie();
//创建一个操作记录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();
Maticsoft.BLL.nr_z_ddwxd_fy wxdfybll = new Maticsoft.BLL.nr_z_ddwxd_fy();
//创建一个操作项目bll
Maticsoft.BLL.nr_z_ddwxd_xm xmbll = new Maticsoft.BLL.nr_z_ddwxd_xm();
public string fanhuicode = "";
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"]);
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);
setwxxm(uid);
upddfy(Convert.ToInt32(uid));
}
else if (Request.QueryString["ddid"] != null && Request.QueryString["ddid"].ToString().Length > 0)
{
addddfy();
Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
kdr.Value = zh.zhanghao;
zt.Text = "待审核";
fdrq.Value = DateTime.Now.ToString("yyyy-MM-dd");
}
else
{
pdquanxian(user.juese);
addddfy();
getwxxm();
Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
kdr.Value = zh.zhanghao;
zt.Text = "待审核";
fdrq.Value = DateTime.Now.ToString("yyyy-MM-dd");
}
}
}
protected void bt_tj_Click(object o, EventArgs e)
{
try
{
string caozuo = "添加";
getmd();
//接收成功参数值
int rtx = 0;
//判断uid是否存在值有值为修改无值为添加
if (id.Value != null && id.Value != "")
{
wxdmodel.id = Convert.ToInt32(id.Value);
if (wxdbll.Update(wxdmodel))
{
rtx = Convert.ToInt32(id.Value);
caozuo = "修改";
}
}
else
{
wxdmodel.wxdh = DBHlper.getbh("WXD-", "nr_z_ddwxd", "wxdh", 4);
wxdh.Text = wxdmodel.wxdh;
rtx = wxdbll.Add(wxdmodel);
}
if (rtx > 0)
{
List<Maticsoft.Model.nr_z_ddwxd_xm> xmmds = new List<Maticsoft.Model.nr_z_ddwxd_xm>();
xmmds = DBHlper.ConvertJsonToEntityListEntity<Maticsoft.Model.nr_z_ddwxd_xm>(wxxmhd.Value);
string deletecmd = "delete from nr_z_ddwxd_xm where wxid='" + rtx + "'";
int ci = 0;
try
{
foreach (Maticsoft.Model.nr_z_ddwxd_xm x in xmmds)
{
ci = ci + 1;
x.wxid = Convert.ToInt32(rtx);
//判断如果存在id的时候且是修改操作时
if (x.id > 0 && Request.QueryString["uid"] != null)
{
xmbll.Update(x);
deletecmd += " and id !=" + x.id;
}
else
{
int mxid = xmbll.Add(x);
deletecmd += " and id !=" + mxid;
}
}
DBHlper.excutecmd(deletecmd);
}
catch
{
Response.Write("<script>alert('外协项目在第'" + ci + "行时保存失败!);</script>");
}
//将session转换对象取值
Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
//拼接字符串插入日志
rizhi.jilu = zh.zhanghao + caozuo + "了外协单,外协单号为:" + wxdh.Text.Trim();
rizhi.yonghuming = zh.zhanghao;
rizhi.riqi = DateTime.Now;
rizhi.leixing = "外协单";
rizhibll.Add(rizhi);
setddfy(rtx);
Response.Redirect("OutsourcingContract_browse.aspx?uid=" + rtx, false);
}
else
{
Response.Redirect("../Common/error.aspx");
}
}
catch (Exception)
{
Response.Redirect("../Common/error.aspx");
}
}
#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)
{
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, "外协单", "view_nr_z_ddwxd", "编辑全部") == false && DBHlper.GetPermission(juese, "外协单", "view_nr_z_ddwxd", "编辑个人") == false)
{
Response.Redirect("../Common/nopower.htm");
}
}
#endregion
#region
private void getwxxm()
{
string biao = "<table id='wxxmtab' class='bule'> <tr id='0' class='tbtilt'>"
+ "<td width='25px' onclick='add_wxxm()'> <img src='../Images_Folder/Button/tjltj.png' width='25px' height='25px' /></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>"
+ "<td><span>备注</span></td></tr>";
cpxx.InnerHtml = biao + "</table>";
}
#endregion
#region
private void setwxxm(string wxid)
{
//修改页面时,首先吧项目明细的表头加载出来
string biao = "<table id='wxxmtab' class='bule'> <tr id='0' class='tbtilt'>"
+ "<td width='25px' onclick='add_wxxm()'> <img src='../Images_Folder/Button/tjltj.png' width='25px' height='25px' /></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>"
+ "<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 width='25px'> <img src='../Images_Folder/Button/tjljh.png' onclick='jianhang(this)' width='25px' height='25px' /></td>"
+ "<td><input type='text' id='djbh" + hcount + "' value='" + r["scdh"] + "' name='" + r["scmxid"] + "' onclick='selectscdxm(" + hcount + ")' Class='inpittxt' readonly /></td>"
+ "<td><input type='text' id='khbh" + hcount + "' value='" + r["khbh"] + "' Class='inpittxt_hx' readonly /></td>"
+ "<td><input type='text' id='cphh" + hcount + "' value='" + r["cphh"] + "' Class='inpittxt_hx' readonly /></td>"
+ "<td><input type='text' id='cpmc" + hcount + "' value='" + r["cpmc"] + "' Class='inpittxt_hx' readonly /></td>"
+ "<td><input type='text' id='zl" + hcount + "' value='" + r["cpzl"] + "' Class='inpittxt_hx' readonly /></td>"
+ "<td><input type='text' id='scfs" + hcount + "' value='" + r["scfs"] + "' Class='inpittxt_hx' readonly /></td>"
+ "<td><input type='text' id='wfsl" + hcount + "' value='" + r["wfsl"] + "' Class='inpittxt_hx' readonly /></td>"
+ "<td><input type='text' id='jhrq" + hcount + "' onclick='new Calendar().show(this);' readonly='readonly' value='" + Convert.ToDateTime(r["jhrq"]).ToString("yyyy-MM-dd") + "' readonly Class='inpittxt' /> </td>"
+ "<td><input type='text' id='beizhu" + hcount + "' value='" + r["bz"] + "' Class='inpittxt' /> </td></tr>";
}
cpxx.InnerHtml = biao + "</table>";
}
#endregion
#region
private void initdata(string did)
{
int idz = Convert.ToInt32(did);
wxdmodel = wxdbll.GetModel(idz);
wxmodel=wxbll.GetModel(Convert.ToInt32(wxdmodel.wxid));
wxid.Value = wxdmodel.wxid.ToString();
wxdh.Text = wxdmodel.wxdh;
wxdw.Value = wxmodel.mingcheng;
fdrq.Value = Convert.ToDateTime(wxdmodel.fdrq).ToString("yyyy-MM-dd").ToString();
zt.Text = wxdmodel.zt;
kdr.Value = wxdmodel.kdr;
shr.Text = wxdmodel.shr;
zlyq.Text = wxdmodel.zlyq;
bz.Text = wxdmodel.bz;
string wxbh = DBHlper.getfirstcolmn("select wx_bh from view_nr_z_ddwxd where id=" + id.Value);
DataTable tbl_lianxiren = DBHlper.Execute("select id,lianxiren,shouji from nr_z_lianxiren_wx where kz_bh='" + wxbh + "'").Tables[0];
if (tbl_lianxiren.Rows.Count > 0)
{
foreach (DataRow dr in tbl_lianxiren.Rows)
{
if (wxdmodel.lianxiren == dr["lianxiren"].ToString())
{
fanhuicode += "<option value='" + dr["id"].ToString() + "' tag='" + dr["shouji"] + "' selected>" + dr["lianxiren"].ToString() + "</option>";
lxfs.Text = dr["shouji"].ToString();
lxrvalue.Value = dr["lianxiren"].ToString();
}
else
{
fanhuicode += "<option value='" + dr["id"].ToString() + "' tag='" + dr["shouji"] + "'>" + dr["lianxiren"].ToString() + "</option>";
}
}
}
}
#endregion
private void getmd()
{
wxdmodel.wxdh =wxdh.Text.Trim();
wxdmodel.wxid = Convert.ToInt32(wxid.Value);
wxdmodel.lianxiren = lxrvalue.Value;
wxdmodel.lxfs = lxfs.Text.Trim();
wxdmodel.fdrq =Convert.ToDateTime(fdrq.Value);
wxdmodel.zt = zt.Text;
wxdmodel.kdr = kdr.Value.Trim();
wxdmodel.shr = shr.Text.Trim();
wxdmodel.zlyq = zlyq.Text.Trim();
wxdmodel.bz = bz.Text.Trim();
}
#region
private void upddfy(int wxdid)
{
DataSet ds = DBHlper.Execute("select * from view_bianma where zhonglei='外协费用'");
string biao = "<table class='bule' id='fyul'><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 width='100'><span>" + i["mingcheng"] + "</span></td><td><input type='text' tag='" + i["mingcheng"] + "' id='fy" + ci + "' onkeyup='doubleshuru(this)' Class='inpittxt' value='" + Convert.ToDouble(fyds.Tables[0].Rows[0]["fyje"]) + "' /></td>";
}
else
{
biao += "<td width='100'><span>" + i["mingcheng"] + "</span></td><td><input type='text' tag='" + i["mingcheng"] + "' id='fy" + ci + "' onkeyup='doubleshuru(this)' Class='inpittxt' value='0' /></td>";
}
}
}
fyxx.InnerHtml = biao + "</tr></table>";
}
#endregion
#region
private void addddfy()
{
DataSet ds = DBHlper.Execute("select * from view_bianma where zhonglei='外协费用'");
string biao = "<table class='bule' id='fyul'><tr>";
int ci = 0;
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow i in ds.Tables[0].Rows)
{
ci = ci + 1;
biao += "<td width='100'><span>" + i["mingcheng"] + "</span></td><td><input type='text' tag='" + i["mingcheng"] + "' onkeyup='doubleshuru(this)' id='fy" + ci + "' value='0' Class='inpittxt' /> </td>";
}
}
fyxx.InnerHtml = biao + "</tr></table>";
}
#endregion
#region
void setddfy(int wxdid)
{
List<Maticsoft.Model.nr_z_ddwxd_fy> xmmds = new List<Maticsoft.Model.nr_z_ddwxd_fy>();
xmmds = DBHlper.ConvertJsonToEntityListEntity<Maticsoft.Model.nr_z_ddwxd_fy>(ddfym.Value);
string deletecmd = "delete from nr_z_ddwxd_fy where wxdid='" + wxdid + "'";
DBHlper.excutecmd(deletecmd);
foreach (Maticsoft.Model.nr_z_ddwxd_fy x in xmmds)
{
x.wxdid = wxdid;
wxdfybll.Add(x);
}
}
#endregion
}