2024-05-18 15:28:29 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Web;
|
|
|
|
|
|
using System.Web.UI;
|
|
|
|
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
using Ajax;
|
|
|
|
|
|
public partial class DemandSheet_Form : CommonPage
|
|
|
|
|
|
{
|
|
|
|
|
|
//创建一个操作记录bll
|
|
|
|
|
|
Maticsoft.BLL.nr_sys_rizhi rizhibll = new Maticsoft.BLL.nr_sys_rizhi();
|
|
|
|
|
|
//创建一个共用的物料需求单模板
|
|
|
|
|
|
Maticsoft.Model.nr_z_shengoudan sgdmodel = new Maticsoft.Model.nr_z_shengoudan();
|
|
|
|
|
|
//创建一个共同的物料需求单bll
|
|
|
|
|
|
Maticsoft.BLL.nr_z_shengoudan sgdbll = new Maticsoft.BLL.nr_z_shengoudan();
|
|
|
|
|
|
//创建一个操作记录模板
|
|
|
|
|
|
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"]);
|
|
|
|
|
|
binddata();
|
|
|
|
|
|
if (Request.QueryString["uid"] != null && Request.QueryString["uid"].ToString().Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
string uid = Request.QueryString["uid"].ToString();
|
|
|
|
|
|
id.Value = uid;
|
|
|
|
|
|
initdata(uid);
|
|
|
|
|
|
pdquanxianbj(user.juese);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Request.QueryString["fid"] != null && Request.QueryString["fid"].ToString().Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
string fid = Request.QueryString["fid"].ToString();
|
|
|
|
|
|
initdata(fid);
|
|
|
|
|
|
}
|
|
|
|
|
|
pdquanxian(user.juese);
|
|
|
|
|
|
txt_sgriqi.Value = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;
|
|
|
|
|
|
bh.Text = "自动生成";
|
|
|
|
|
|
txt_shengouren.Text = user.zhanghao;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
Utility.RegisterTypeForAjax(typeof(DemandSheet_Form));
|
|
|
|
|
|
}
|
|
|
|
|
|
#region 用来初始化绑定下拉框等值
|
|
|
|
|
|
private void binddata()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
txt_yhriqi.Value = DateTime.Now.ToString("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 修改时获取真正数据值
|
|
|
|
|
|
private void initdata(string did)
|
|
|
|
|
|
{
|
|
|
|
|
|
DataTable dtsgd=DBHlper.Execute("select * from view_nr_z_shengoudan where id="+did).Tables[0];
|
|
|
|
|
|
if (dtsgd != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
bh.Text = dtsgd.Rows[0]["sgdbianhao"].ToString();
|
|
|
|
|
|
txt_shengchandan.Value = dtsgd.Rows[0]["scdbh"].ToString();
|
|
|
|
|
|
txt_wlbianhao.Value = dtsgd.Rows[0]["wlbh"].ToString();
|
|
|
|
|
|
txt_wlmingcheng.Value = dtsgd.Rows[0]["mingcheng"].ToString();
|
|
|
|
|
|
txt_wlpinpai.Value = dtsgd.Rows[0]["pinpai"].ToString();
|
|
|
|
|
|
txt_wlguige.Value = dtsgd.Rows[0]["guige"].ToString();
|
|
|
|
|
|
txt_yhriqi.Value=Convert.ToDateTime ( dtsgd.Rows[0]["yhriqi"]).ToString("yyyy-MM-dd").ToString();
|
|
|
|
|
|
txt_qxshuliang.Value = dtsgd.Rows[0]["xuqiushuliang"].ToString();
|
|
|
|
|
|
txt_kucun.Text = dtsgd.Rows[0]["kucun"].ToString();
|
|
|
|
|
|
txt_shengoushu.Text = dtsgd.Rows[0]["shengoushu"].ToString();
|
|
|
|
|
|
txt_shengouren.Text = dtsgd.Rows[0]["shengouren"].ToString();
|
|
|
|
|
|
lbl_zt.Value = dtsgd.Rows[0]["zt"].ToString();
|
|
|
|
|
|
txt_beizhu.Text = dtsgd.Rows[0]["beizhu"].ToString();
|
|
|
|
|
|
txt_danwei.Value = dtsgd.Rows[0]["danwei"].ToString();
|
|
|
|
|
|
wlidhidden.Value = dtsgd.Rows[0]["wlid"].ToString();
|
|
|
|
|
|
scdidhidden.Value = dtsgd.Rows[0]["scdid"].ToString();
|
|
|
|
|
|
txt_sgriqi.Value = Convert.ToDateTime(dtsgd.Rows[0]["riqi"]).ToString("yyyy-MM-dd").ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 获取页面参数赋值model对象
|
|
|
|
|
|
private void getmd()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
sgdmodel.sgdbianhao= bh.Text;
|
|
|
|
|
|
sgdmodel.scdid =scdidhidden.Value;
|
|
|
|
|
|
sgdmodel.wlid = Convert.ToInt32(wlidhidden.Value);
|
|
|
|
|
|
sgdmodel.shengoushu = Convert.ToDecimal(txt_shengoushu.Text);
|
|
|
|
|
|
if (!string.IsNullOrEmpty(txt_qxshuliang.Value))
|
|
|
|
|
|
{
|
|
|
|
|
|
sgdmodel.xuqiushuliang = Convert.ToDecimal(Convert.ToDouble(txt_qxshuliang.Value));
|
|
|
|
|
|
}
|
|
|
|
|
|
sgdmodel.shengouren = txt_shengouren.Text;
|
|
|
|
|
|
sgdmodel.yhriqi = Convert.ToDateTime(txt_yhriqi.Value);
|
|
|
|
|
|
sgdmodel.riqi = Convert.ToDateTime(txt_sgriqi.Value);
|
|
|
|
|
|
sgdmodel.zt = lbl_zt.Value;
|
|
|
|
|
|
sgdmodel.beizhu = txt_beizhu.Text.Trim();
|
|
|
|
|
|
sgdmodel.zt = "待审核";
|
|
|
|
|
|
sgdmodel.cgzt = "待采购";
|
|
|
|
|
|
//给日志模板赋值
|
|
|
|
|
|
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");
|
|
|
|
|
|
}
|
2024-05-21 15:05:24 +08:00
|
|
|
|
if (DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "添加") == false)
|
2024-05-18 15:28:29 +08:00
|
|
|
|
{
|
|
|
|
|
|
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");
|
|
|
|
|
|
}
|
2024-05-21 15:05:24 +08:00
|
|
|
|
if (DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "编辑个人") == false && DBHlper.GetPermission(juese, "物料需求单", "nr_z_shengoudan", "编辑全部") == false)
|
2024-05-18 15:28:29 +08:00
|
|
|
|
{
|
|
|
|
|
|
Response.Redirect("../Common/nopower.htm");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
protected void bt_tj_Click(object sender, EventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
string caozuo = "添加";
|
|
|
|
|
|
getmd();
|
|
|
|
|
|
//接收成功参数值
|
|
|
|
|
|
int rtx = 0;
|
|
|
|
|
|
//判断uid是否存在值,有值为修改,无值为添加
|
|
|
|
|
|
if (id.Value != null && id.Value != "")
|
|
|
|
|
|
{
|
|
|
|
|
|
sgdmodel.id = Convert.ToInt32(id.Value);
|
|
|
|
|
|
if (sgdbll.Update(sgdmodel))
|
|
|
|
|
|
{
|
|
|
|
|
|
rtx = Convert.ToInt32(id.Value);
|
|
|
|
|
|
caozuo = "修改";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
sgdmodel.sgdbianhao = DBHlper.getbh("SG-", "nr_z_shengoudan", "sgdbianhao", 4);
|
|
|
|
|
|
bh.Text = sgdmodel.sgdbianhao;
|
|
|
|
|
|
rtx = sgdbll.Add(sgdmodel);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (rtx > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//将session转换对象取值
|
|
|
|
|
|
Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
|
|
|
|
rizhi.yonghuming = zh.zhanghao;
|
|
|
|
|
|
//拼接字符串插入日志
|
|
|
|
|
|
rizhi.jilu = zh.zhanghao + caozuo + "了物料需求单,物料需求单号为:" + bh.Text.Trim();
|
|
|
|
|
|
rizhibll.Add(rizhi);
|
|
|
|
|
|
Response.Redirect("DemandSheet_browse.aspx?uid=" + rtx, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Response.Redirect("../Common/error.aspx");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
Response.Redirect("../Common/error.aspx");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 根据生产编号筛选生产单中的物料
|
|
|
|
|
|
[Ajax.AjaxMethod]
|
|
|
|
|
|
public string getwlidsbyscd(string scdh)
|
|
|
|
|
|
{
|
|
|
|
|
|
string cmd = "select wlbh from nr_z_scd_xm where scd_id=(select id from nr_z_scd where bh='" + scdh + "')";
|
|
|
|
|
|
string wlbhs = "";
|
|
|
|
|
|
DataTable wldt = DBHlper.Execute(cmd).Tables[0];
|
|
|
|
|
|
foreach (DataRow dr in wldt.Rows)
|
|
|
|
|
|
{
|
|
|
|
|
|
wlbhs +=dr["wlbh"]+",";
|
|
|
|
|
|
}
|
|
|
|
|
|
wlbhs = wlbhs.TrimEnd(',');
|
|
|
|
|
|
return wlbhs;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
}
|