CeramicProject/newyt/Module_data/Productin_Form.aspx.cs

187 lines
6.2 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 Productin_Form : System.Web.UI.Page
{
//创建一个操作记录bll
Maticsoft.BLL.nr_sys_rizhi rizhibll = new Maticsoft.BLL.nr_sys_rizhi();
//创建一个共用的申购单模板
Maticsoft.Model.nr_z_cpck cpckmodel = new Maticsoft.Model.nr_z_cpck();
//创建一个共同的申购单bll
Maticsoft.BLL.nr_z_cpck cpckbll = new Maticsoft.BLL.nr_z_cpck();
//创建一个操作记录模板
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"]);
if (Request.QueryString["uid"] != null && Request.QueryString["uid"].ToString().Length > 0)
{
string uid = Request.QueryString["uid"].ToString();
id.Value = uid;
initdata(Convert.ToInt32(uid));
pdquanxianbj(user.juese);
}
else
{
pdquanxian(user.juese);
riqi.Value = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;
jingshouren.Value = user.zhanghao;
shr.Value = user.zhanghao;
}
}
}
#region
private void initdata(int did)
{
cpckmodel = cpckbll.GetModel(did);
ckdh.Text = cpckmodel.ckbh;
riqi.Value = cpckmodel.riqi.ToString("yyyy-MM-dd");
scdh.Value = cpckmodel.scdh;
khming.Value = cpckmodel.khmc;
cpbh.Value = cpckmodel.cpbh;
cpmc.Value = cpckmodel.cpmc;
danjia.Value = cpckmodel.cpdj.ToString();
guige.Value = cpckmodel.guige.ToString();
zzshuliang.Value = cpckmodel.zzsl.ToString();
lingtou.Value = cpckmodel.lt.ToString();
shuliang.Value = cpckmodel.sl.ToString();
danwei.Value = cpckmodel.danwei;
lxr.Value = cpckmodel.lxr;
zongjine.Value = cpckmodel.zje.ToString();
lxdh.Value = cpckmodel.lxdh;
jingshouren.Value = cpckmodel.jsr;
shr.Value = cpckmodel.shr;
dizhi.Value = cpckmodel.shdizhi;
txt_beizhu.Text = cpckmodel.beizhu;
zhuangtai.Value = cpckmodel.zt;
}
#endregion
#region model对象
private void getmd()
{
cpckmodel.ckbh = ckdh.Text;
cpckmodel.riqi = Convert.ToDateTime(riqi.Value);
cpckmodel.scdh = scdh.Value;
cpckmodel.khmc = khming.Value;
cpckmodel.cpbh = cpbh.Value;
cpckmodel.cpmc = cpmc.Value;
cpckmodel.cpdj = Convert.ToDecimal(danjia.Value);
cpckmodel.guige = Convert.ToDecimal(guige.Value);
cpckmodel.zzsl = Convert.ToInt32(zzshuliang.Value);
cpckmodel.lt = Convert.ToDecimal(lingtou.Value);
cpckmodel.sl = Convert.ToDecimal(shuliang.Value);
cpckmodel.danwei = danwei.Value;
cpckmodel.lxr = lxr.Value;
cpckmodel.zje = Convert.ToDecimal(zongjine.Value);
cpckmodel.lxdh = lxdh.Value;
cpckmodel.jsr = jingshouren.Value;
cpckmodel.shr = shr.Value;
cpckmodel.shdizhi = dizhi.Value;
cpckmodel.beizhu = txt_beizhu.Text;
cpckmodel.zt = zhuangtai.Value;
}
#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_cprk", "添加") == 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_cprk", "编辑个人") == false
&& DBHlper.GetPermission(juese, "成品入库", "nr_z_cprk", "编辑全部") == false)
{
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 != "")
{
cpckmodel.id = Convert.ToInt32(id.Value);
if (cpckbll.Update(cpckmodel))
{
rtx = Convert.ToInt32(id.Value);
caozuo = "修改";
}
}
else
{
cpckmodel.ckbh = DBHlper.getbh("CPCK-", "nr_z_cpck", "ckbh", 4);
// bh.Text = sgdmodel.sgdbianhao;
rtx = cpckbll.Add(cpckmodel);
}
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 + "了成品出库,出库单号为:" + ckdh.Text.Trim();
rizhi.leixing = "成品出库";
rizhi.riqi = DateTime.Now;
rizhibll.Add(rizhi);
Response.Redirect("Productin_browse.aspx?uid=" + rtx, false);
}
else
{
Response.Redirect("../Common/error.aspx");
}
}
catch (Exception)
{
Response.Redirect("../Common/error.aspx");
}
}
}