126 lines
4.4 KiB
C#
126 lines
4.4 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 System.Data.SqlClient;
|
|
|
|
public partial class Materiel_browse : CommonPage
|
|
{
|
|
//创建一个共用的物料bll
|
|
Maticsoft.BLL.nr_z_wuliao wuliaobll = new Maticsoft.BLL.nr_z_wuliao();
|
|
|
|
//创建一个物料模板
|
|
Maticsoft.Model.nr_z_wuliao wuliaomd = new Maticsoft.Model.nr_z_wuliao();
|
|
//创建一个操作记录模板
|
|
Maticsoft.Model.nr_sys_rizhi rizhi = new Maticsoft.Model.nr_sys_rizhi();
|
|
//创建一个操作记录bll
|
|
Maticsoft.BLL.nr_sys_rizhi rizhibll = new Maticsoft.BLL.nr_sys_rizhi();
|
|
Maticsoft.BLL.nr_sys_bianma bianma = new Maticsoft.BLL.nr_sys_bianma();
|
|
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"]);
|
|
pdquanxian(user.juese);
|
|
if (Request.QueryString["uid"] != null && Request.QueryString["uid"] != "")
|
|
{
|
|
id.Value = Request.QueryString["uid"].ToString();
|
|
}
|
|
initdata(id.Value);
|
|
|
|
}
|
|
}
|
|
|
|
#region 修改时获取真正数据值
|
|
private void initdata(string wx_bh)
|
|
{
|
|
int idz = Convert.ToInt32(wx_bh);
|
|
wuliaomd= wuliaobll.GetModel(idz);
|
|
if (wuliaomd != null)
|
|
{
|
|
bh.Text = wuliaomd.wlbh;
|
|
mingcheng.Text = wuliaomd.mingcheng;
|
|
pinpai.Text = wuliaomd.pinpai;
|
|
zhonglei.Text = bianma.GetModel(Convert.ToInt32(wuliaomd.zhonglei)).mingcheng;
|
|
danwei.Text =bianma.GetModel(Convert.ToInt32(wuliaomd.danwei)).mingcheng;
|
|
cangku.Text = wuliaomd.kufang;
|
|
zdkc.Text = Convert.ToDouble(wuliaomd.zuidkucun).ToString();
|
|
zgkc.Text = Convert.ToDouble(wuliaomd.zuigkucun).ToString();
|
|
riqi.Text = DateTime.Parse(wuliaomd.riqi.ToString()).ToString("yyyy-MM-dd");
|
|
changdu.Text = Convert.ToDouble(wuliaomd.changdu).ToString();
|
|
kuandu.Text = Convert.ToDouble(wuliaomd.kuandu).ToString();
|
|
guige.Text = wuliaomd.guige;
|
|
beizhu.Text = wuliaomd.beizhu;
|
|
}
|
|
}
|
|
#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_wuliao", "查看全部") == false)
|
|
{
|
|
Response.Redirect("../Common/nopower.htm");
|
|
}
|
|
|
|
if (DBHlper.GetPermission(juese, "物料档案", "nr_z_wuliao", "编辑") )
|
|
{
|
|
bt_tj.Visible = true;
|
|
}
|
|
if (DBHlper.GetPermission(juese, "物料档案", "nr_z_wuliao", "删除") )
|
|
{
|
|
shanchu.Visible = true;
|
|
}
|
|
if (DBHlper.GetPermission(juese, "物料档案", "nr_z_wuliao", "添加") )
|
|
{
|
|
fuzhi.Visible = true;
|
|
bt_add.Visible = true;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
protected void Shanchu_Click(object sender, EventArgs e)
|
|
{
|
|
if (Convert.ToDecimal(DBHlper.getfirstcolmn("select sum(kucun) from nr_z_wuliao where wlbh='" + bh.Text + "'")) > 0) {
|
|
z_error.Text = "该物料已有库存,不能删除!";
|
|
return;
|
|
}
|
|
|
|
|
|
wuliaomd = wuliaobll.GetModel( Convert.ToInt32(id.Value));
|
|
wuliaomd.zt = 0;
|
|
bool ci = wuliaobll.Update(wuliaomd);
|
|
|
|
if (ci)
|
|
{
|
|
//给日志模板赋值
|
|
rizhi.riqi = DateTime.Now;
|
|
rizhi.leixing = "物料档案";
|
|
//将session转换对象取值
|
|
Maticsoft.Model.nr_z_yhzh zh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
//拼接字符串插入日志
|
|
rizhi.jilu = zh.zhanghao + "删除了物料档案,档案编号为:" + bh.Text.Trim();
|
|
rizhi.yonghuming = zh.zhanghao.ToString();
|
|
rizhibll.Add(rizhi);
|
|
Response.Redirect("Materiel_list.aspx", false);
|
|
}
|
|
else
|
|
{
|
|
Response.Write("<script>alert('删除失败')</script>");
|
|
}
|
|
}
|
|
} |