238 lines
7.6 KiB
C#
238 lines
7.6 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.UI;
|
|||
|
|
using System.Web.UI.WebControls;
|
|||
|
|
using Maticsoft.BLL;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Data.SqlClient;
|
|||
|
|
using Ajax;
|
|||
|
|
public partial class OtherOut_Form : CommonPage
|
|||
|
|
{
|
|||
|
|
//所有客户名称
|
|||
|
|
public string wuliaomingtishi = "";
|
|||
|
|
//创建一个共用的其它出库bll层
|
|||
|
|
Maticsoft.BLL.nr_z_qtck qtckbll = new Maticsoft.BLL.nr_z_qtck();
|
|||
|
|
//创建一个共用的其它出库模板
|
|||
|
|
Maticsoft.Model.nr_z_qtck qtck = new Maticsoft.Model.nr_z_qtck();
|
|||
|
|
//创建一个共用的编码bll层
|
|||
|
|
Maticsoft.BLL.nr_sys_bianma bmb = new Maticsoft.BLL.nr_sys_bianma();
|
|||
|
|
//创建一个共用的类型BLL层
|
|||
|
|
Maticsoft.BLL.nr_sys_leixing bmlx = new Maticsoft.BLL.nr_sys_leixing();
|
|||
|
|
//创建一个操作记录模板
|
|||
|
|
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();
|
|||
|
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
Utility.RegisterTypeForAjax(typeof(OtherOut_Form));
|
|||
|
|
if (!IsPostBack)
|
|||
|
|
{
|
|||
|
|
if (Session["user"] == null)
|
|||
|
|
{
|
|||
|
|
Response.Redirect("../index.aspx");
|
|||
|
|
}
|
|||
|
|
//获取角色权限
|
|||
|
|
Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]);
|
|||
|
|
jsr.Value = user.zhanghao;
|
|||
|
|
binddata();
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
pdquanxian(user.juese);
|
|||
|
|
if (Request.QueryString["fid"] != null && Request.QueryString["fid"].ToString().Length > 0)
|
|||
|
|
{
|
|||
|
|
string fid = Request.QueryString["fid"].ToString();
|
|||
|
|
initdata(fid);
|
|||
|
|
}
|
|||
|
|
//赋值默认值
|
|||
|
|
ckdh.Text = "自动生成";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#region 用来初始化绑定下拉框等值
|
|||
|
|
private void binddata()
|
|||
|
|
{
|
|||
|
|
zt.Value = "待确认";
|
|||
|
|
DataSet hylx = bmlx.GetAllList();
|
|||
|
|
DataRow[] dr = hylx.Tables[0].Select("leixing='部门'");
|
|||
|
|
if (dr != null && dr.Length > 0)
|
|||
|
|
{
|
|||
|
|
DataSet hy = bmb.GetList("zhongleiid='" + dr[0]["id"] + "'");
|
|||
|
|
if (hy != null)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
bm.DataSource = hy.Tables[0].DefaultView;
|
|||
|
|
bm.DataValueField = "mingcheng";
|
|||
|
|
bm.DataTextField = "mingcheng";
|
|||
|
|
bm.DataBind();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region 修改时获取真正数据值
|
|||
|
|
private void initdata(string did)
|
|||
|
|
{
|
|||
|
|
int idz = Convert.ToInt32(did);
|
|||
|
|
qtck = qtckbll.GetModel(idz);
|
|||
|
|
if (qtck != null)
|
|||
|
|
{
|
|||
|
|
ckdh.Text = qtck.ckdh;
|
|||
|
|
riqi.Value = DateTime.Parse(qtck.ckrq.ToString()).ToString("yyyy-MM-dd");
|
|||
|
|
cangku.Value = qtck.kf;
|
|||
|
|
scdh.Value = qtck.scdbh;
|
|||
|
|
ckzl.Text = qtck.cklx;
|
|||
|
|
wlbh.Value = qtck.wlbh;
|
|||
|
|
wlmc.Value = qtck.wlmc;
|
|||
|
|
wlpp.Value = qtck.wlpp;
|
|||
|
|
guige.Value = DBHlper.getfirstcolmn("select top 1 guige from nr_z_wuliao where wlbh='" + qtck.wlbh + "' and zt=1");
|
|||
|
|
sl.Value = qtck.sl.ToString();
|
|||
|
|
danwei.Value = qtck.wldw;
|
|||
|
|
jsr.Value = qtck.jsr;
|
|||
|
|
beizhu.Text = qtck.bz;
|
|||
|
|
bm.Text = qtck.bm;
|
|||
|
|
zt.Value = qtck.zt;
|
|||
|
|
dj.Value = DBHlper.getfirstcolmn("select top 1 dj from view_nr_z_wuliao where wlbh='" + qtck.wlbh + "' and zt=1");
|
|||
|
|
jine.Value = qtck.jine.ToString();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region 获取页面参数赋值model对象
|
|||
|
|
private void getmd()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//给日志模板赋值
|
|||
|
|
rizhi.riqi = DateTime.Now;
|
|||
|
|
rizhi.leixing = "材料其它出库";
|
|||
|
|
//给其他入库赋值
|
|||
|
|
qtck.ckdh = ckdh.Text;
|
|||
|
|
qtck.ckrq =Convert.ToDateTime(riqi.Value);
|
|||
|
|
qtck.kf = cangku.Value;
|
|||
|
|
qtck.cklx = ckzl.Text;
|
|||
|
|
qtck.wlbh = wlbh.Value;
|
|||
|
|
qtck.wlmc = wlmc.Value;
|
|||
|
|
qtck.wlpp = wlpp.Value;
|
|||
|
|
qtck.sl = Convert.ToDecimal(sl.Value);
|
|||
|
|
qtck.wldw = danwei.Value;
|
|||
|
|
qtck.jsr = jsr.Value;
|
|||
|
|
qtck.bz = beizhu.Text;
|
|||
|
|
qtck.scdbh = scdh.Value;
|
|||
|
|
qtck.bm = bm.Text;
|
|||
|
|
qtck.zt = zt.Value;
|
|||
|
|
|
|||
|
|
string dj = DBHlper.getfirstcolmn("select isnull(dj,0) from view_nr_z_wuliao where wlbh='" + wlbh.Value + "'");
|
|||
|
|
|
|||
|
|
qtck.jine = Convert.ToDecimal(sl.Value) * Convert.ToDecimal(dj);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#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.getqx(juese, "其它出库", "nr_z_qtck", "添加") == 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.getqx(juese, "其它出库", "nr_z_qtck", "编辑个人") == false && DBHlper.getqx(juese, "其它出库", "nr_z_qtck", "编辑全部") == false)
|
|||
|
|
{
|
|||
|
|
Response.Redirect("../Common/nopower.htm");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 查询物料名称是否重复
|
|||
|
|
[Ajax.AjaxMethod()]
|
|||
|
|
public int serchmingcheng(string str,string ckname)
|
|||
|
|
{
|
|||
|
|
string cmd = string.Format("select count(*) from nr_z_wuliao where mingcheng='{0}' and kufang='{1}' ", str.Replace(" ", ""), ckname.Replace(" ", ""));
|
|||
|
|
int count = DBHlper.getcount(cmd);
|
|||
|
|
return count;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
//保存操作
|
|||
|
|
protected void bt_tj_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
string caozuo = "添加";
|
|||
|
|
getmd();
|
|||
|
|
//接收成功参数值
|
|||
|
|
int rtx = 0;
|
|||
|
|
//判断uid是否存在值,有值为修改,无值为添加
|
|||
|
|
if (id.Value != null && id.Value != "")
|
|||
|
|
{
|
|||
|
|
qtck.id = Convert.ToInt32(id.Value);
|
|||
|
|
if (qtckbll.Update(qtck))
|
|||
|
|
{
|
|||
|
|
rtx = Convert.ToInt32(id.Value);
|
|||
|
|
caozuo = "修改";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
qtck.ckdh = DBHlper.getbh("QTCK-", "nr_z_qtck", "ckdh", 4);
|
|||
|
|
ckdh.Text = qtck.ckdh;
|
|||
|
|
rtx = qtckbll.Add(qtck);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
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();
|
|||
|
|
rizhibll.Add(rizhi);
|
|||
|
|
|
|||
|
|
Response.Redirect("OtherOut_browse.aspx?uid=" + rtx, false);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Response.Redirect("../Common/error.aspx");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
catch (Exception)
|
|||
|
|
{
|
|||
|
|
Response.Redirect("../Common/error.aspx");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|