253 lines
8.5 KiB
C#
253 lines
8.5 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 OtherEntries_browse : System.Web.UI.Page
|
|
{
|
|
//创建一个共用的其它入库bll层
|
|
Maticsoft.BLL.nr_z_qtrk qtrkbll = new Maticsoft.BLL.nr_z_qtrk();
|
|
//创建一个共用的其它入库模板
|
|
Maticsoft.Model.nr_z_qtrk qtrk = new Maticsoft.Model.nr_z_qtrk();
|
|
//创建一个操作记录模板
|
|
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_z_wuliao wlbll = new Maticsoft.BLL.nr_z_wuliao();
|
|
Maticsoft.Model.nr_z_wuliao wlmodel = new Maticsoft.Model.nr_z_wuliao();
|
|
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"] != "")
|
|
{
|
|
id.Value = Request.QueryString["uid"].ToString();
|
|
}
|
|
initdata(id.Value);
|
|
pdquanxian(user.juese);
|
|
|
|
}
|
|
}
|
|
|
|
#region 获取页面参数赋值model对象
|
|
private void getmd()
|
|
{
|
|
qtrk=qtrkbll.GetModel(Convert.ToInt32(id.Value));
|
|
//给日志模板赋值
|
|
rizhi.riqi = DateTime.Now;
|
|
rizhi.leixing = "材料其它入库";
|
|
|
|
|
|
}
|
|
#endregion
|
|
#region 修改时获取真正数据值
|
|
private void initdata(string rkid)
|
|
{
|
|
int idz = Convert.ToInt32(rkid);
|
|
qtrk = qtrkbll.GetModel(idz);
|
|
if (qtrk != null)
|
|
{
|
|
bh.Text = qtrk.rkbh;
|
|
riqi.Text = DateTime.Parse(qtrk.riqi.ToString()).ToString("yyyy-MM-dd");
|
|
cangku.Text = qtrk.kf;
|
|
rklx.Text = qtrk.rklx;
|
|
wlbh.Text = qtrk.wlbh;
|
|
wlmc.Text = qtrk.wlmc;
|
|
guige.Text = DBHlper.getfirstcolmn("select top 1 guige from nr_z_wuliao where wlbh='" + qtrk.wlbh + "' and zt=1");
|
|
wlpp.Text = qtrk.wlpp;
|
|
wlzl.Text = qtrk.zl;
|
|
sl.Text = qtrk.sl.ToString();
|
|
danwei.Text = qtrk.dw;
|
|
dj.Text = qtrk.dj.ToString();
|
|
jine.Text = qtrk.je.ToString();
|
|
jsr.Text = qtrk.jsr;
|
|
gysbh.Text = qtrk.gysbh;
|
|
gysmc.Text = DBHlper.getfirstcolmn("select mingcheng from nr_z_gyshang where bianhao='" + qtrk.gysbh + "'");
|
|
beizhu.Text = qtrk.bz;
|
|
wz.Text = qtrk.wz;
|
|
zt.Text = qtrk.zt;
|
|
}
|
|
}
|
|
#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_qtrk", "查看全部") == false && DBHlper.GetPermission(juese, "其它入库", "nr_z_qtrk", "查看个人") == false)
|
|
{
|
|
Response.Redirect("../Common/nopower.htm");
|
|
}
|
|
|
|
if (DBHlper.GetPermission(juese, "其它入库", "nr_z_qtrk", "编辑个人") && jsr.Text == user.zhanghao)
|
|
{
|
|
bt_tj.Visible = true;
|
|
|
|
}
|
|
if (DBHlper.GetPermission(juese, "其它入库", "nr_z_qtrk", "编辑全部"))
|
|
{
|
|
bt_tj.Visible = true;
|
|
|
|
}
|
|
if (DBHlper.GetPermission(juese, "其它入库", "nr_z_qtrk", "删除个人") && jsr.Text == user.zhanghao)
|
|
{
|
|
shanchu.Visible = true;
|
|
}
|
|
if (DBHlper.GetPermission(juese, "其它入库", "nr_z_qtrk", "删除全部"))
|
|
{
|
|
shanchu.Visible = true;
|
|
|
|
}
|
|
if (DBHlper.GetPermission(juese, "其它入库", "nr_z_qtrk", "入库确认"))
|
|
{
|
|
rkqr.Visible = true;
|
|
}
|
|
|
|
if (DBHlper.GetPermission(juese, "其它入库", "nr_z_qtrk", "入库冲红"))
|
|
{
|
|
rkch.Visible = true;
|
|
|
|
}
|
|
if (zt.Text == "已确认")
|
|
{
|
|
rkqr.Enabled = false;
|
|
rkqr.BackColor = System.Drawing.Color.Gray;
|
|
shanchu.Enabled = false;
|
|
shanchu.BackColor = System.Drawing.Color.Gray;
|
|
bt_tj.Enabled = false;
|
|
bt_tj.BackColor = System.Drawing.Color.Gray;
|
|
}
|
|
if (zt.Text == "待确认")
|
|
{
|
|
rkch.Enabled = false;
|
|
rkch.BackColor = System.Drawing.Color.Gray;
|
|
}
|
|
|
|
if (DBHlper.GetPermission(juese, "其它入库", "nr_z_qtrk", "添加"))
|
|
{
|
|
bt_add.Visible = true;
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
protected void rkqr_Click(object sender, EventArgs e)
|
|
{
|
|
getmd();
|
|
qtrk.zt = "已确认";
|
|
qtrk.riqi = DateTime.Now;
|
|
|
|
int fh =0;
|
|
DataTable kcdt = DBHlper.Execute("select * from nr_z_wuliao where wlbh='" + wlbh.Text + "' and kufang='" + cangku.Text + "'").Tables[0];
|
|
if (kcdt.Rows.Count > 0)
|
|
{
|
|
string sql = "update nr_z_wuliao set kucun=kucun+" + sl.Text + ",jine=ISNULL(jine,0)+" + jine.Text + " where id=" + kcdt.Rows[0]["id"];
|
|
fh = DBHlper.excutecmd(sql);
|
|
qtrkbll.Update(qtrk);
|
|
}
|
|
else {
|
|
|
|
|
|
}
|
|
|
|
//将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;
|
|
rizhibll.Add(rizhi);
|
|
if (fh > 0)
|
|
{
|
|
Response.Redirect("OtherEntries_browse.aspx?uid=" + id.Value, false);
|
|
}
|
|
else
|
|
{
|
|
z_error.Text = "入库确认失败!";
|
|
}
|
|
}
|
|
protected void rkch_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
string cslsql = "select isnull(kucun,0) from nr_z_wuliao where wlbh='" + wlbh.Text + "' and kufang='" + cangku.Text + "'";
|
|
string sjsl = DBHlper.getfirstcolmn(cslsql);
|
|
if (sjsl != "" && sjsl.Length > 0)
|
|
{
|
|
decimal kcsl = Convert.ToDecimal(sjsl);
|
|
if (kcsl < Convert.ToDecimal(sl.Text))
|
|
{
|
|
z_error.Text = "库存不足,无法进行冲红操作!";
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
z_error.Text = "库存不足,无法进行冲红操作!";
|
|
return;
|
|
}
|
|
|
|
if (zt.Text == "待确认")
|
|
{
|
|
z_error.Text = "采购未入库确认,冲红操作失败!";
|
|
return;
|
|
}
|
|
|
|
string sql = "update nr_z_wuliao set kucun=kucun-" + sl.Text + ",jine=ISNULL(jine,0)-" + jine.Text + " where wlbh='" + wlbh.Text + "' and kufang='" + cangku.Text + "'";
|
|
int fh = DBHlper.excutecmd(sql);
|
|
if (fh > 0)
|
|
{
|
|
getmd();
|
|
qtrk.zt = "待确认";
|
|
if (qtrkbll.Update(qtrk))
|
|
{
|
|
//将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;
|
|
rizhibll.Add(rizhi);
|
|
Response.Redirect("OtherEntries_browse.aspx?uid=" + id.Value, false);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
z_error.Text = "入库冲红失败!";
|
|
}
|
|
|
|
}
|
|
protected void shanchu_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
if (zt.Text == "已确认")
|
|
{
|
|
z_error.Text = "已确认入库,不能进行删除操作!";
|
|
return;
|
|
}
|
|
getmd();
|
|
if (qtrkbll.Delete(Convert.ToInt32(id.Value)))
|
|
{
|
|
//将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;
|
|
rizhibll.Add(rizhi);
|
|
Response.Redirect("OtherEntries_list.aspx", false);
|
|
}
|
|
}
|
|
protected void bt_tj_Click(object sender, EventArgs e)
|
|
{
|
|
Response.Redirect("OtherEntries_Form.aspx?uid=" + id.Value);
|
|
}
|
|
} |