236 lines
9.1 KiB
C#
236 lines
9.1 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.IO;
|
|
|
|
public partial class Product_browse : System.Web.UI.Page
|
|
{
|
|
Maticsoft.Model.nr_z_cpkc cpkcmodel = new Maticsoft.Model.nr_z_cpkc();
|
|
Maticsoft.BLL.nr_z_cpkc cpkcbll = new Maticsoft.BLL.nr_z_cpkc();
|
|
//创建一个操作记录模板
|
|
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)
|
|
{
|
|
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(Convert.ToInt32(id.Value));
|
|
pdquanxian(user.juese);
|
|
setxmxq(id.Value);
|
|
//getscyl();
|
|
}
|
|
|
|
}
|
|
#region 获取真正数据值
|
|
private void initdata(int did)
|
|
{
|
|
DataTable dt = DBHlper.Execute("select * from view_nr_z_cpkc where id=" + did).Tables[0];
|
|
|
|
if(dt.Rows.Count>0){
|
|
cpbh.Text = dt.Rows[0]["cpbh"].ToString();
|
|
cpmc.Text = dt.Rows[0]["cpmc"].ToString();
|
|
riqi.Text = dt.Rows[0]["riqi"].ToString();
|
|
gg.Text = dt.Rows[0]["gg"].ToString();
|
|
//zhongliang.Text = dt.Rows[0]["zhongliang"].ToString();
|
|
//zl.Text = dt.Rows[0]["zl"].ToString() ;
|
|
//tiji.Text = dt.Rows[0]["tiji"].ToString();
|
|
dw.Text = dt.Rows[0]["dw"].ToString();
|
|
dj.Text = dt.Rows[0]["dj"].ToString();
|
|
jsr.Text = dt.Rows[0]["jsr"].ToString();
|
|
bz.Text = dt.Rows[0]["bz"].ToString();
|
|
tp.Src = "../Client_Folder/" + dt.Rows[0]["tp"].ToString() + "";
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
#region 获取项目需求
|
|
private void setxmxq(string cpid)
|
|
{
|
|
//加载前段项目
|
|
string qdgjstring = "<table id='qdxmtb'class='bule'><tr class='tbtilt'><td><span>需求项目</span></td><td><span>物料编号</span></td><td><span>物料名称</span></td><td><span>用量</span></td><td><span>需求项目</span></td><td><span>物料编号</span></td><td><span>物料名称</span></td><td><span>用量</span></td></tr> ";
|
|
string getgjsql = "select * from view_nr_z_cpkc_wlxq where cpid='" + id.Value + "'";
|
|
DataSet ds = DBHlper.Execute(getgjsql);
|
|
int ges = 0;
|
|
if (ds != null && ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
|
|
foreach(DataRow r in ds.Tables[0].Rows)
|
|
{
|
|
ges = ges + 1;
|
|
if (ges == 1)
|
|
{
|
|
qdgjstring += "<tr><td><span>" + r["xmmc"].ToString() + "</span></td><td><span>" + r["wlbh"].ToString() + "</span></td><td ><span>" + r["wlmc"].ToString() + "</span></td><td><span>" + Convert.ToDouble(r["xqyl"]).ToString() + "</span></td>";
|
|
}
|
|
else
|
|
{
|
|
qdgjstring += "<td><span>" + r["xmmc"].ToString() + "</span></td><td><span>" + r["wlbh"].ToString() + "</span></td><td ><span>" + r["wlmc"].ToString() + "</span></td><td><span>" + Convert.ToDouble(r["xqyl"]).ToString() + "</span></td></tr>";
|
|
ges = 0;
|
|
}
|
|
|
|
}
|
|
if (ges == 1)
|
|
{
|
|
qdgjstring += "<td ></td><td></td><td></td><td></td></tr>";
|
|
ges = 0;
|
|
}
|
|
}
|
|
xqwldiv.InnerHtml = qdgjstring + "</table>";
|
|
}
|
|
#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_cpkc", "查看全部") == false && DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "查看个人") == false)
|
|
{
|
|
Response.Redirect("../Common/nopower.htm");
|
|
}
|
|
|
|
if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "编辑个人") && jsr.Text == user.zhanghao)
|
|
{
|
|
bt_tj.Visible = true;
|
|
|
|
}
|
|
if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "编辑全部"))
|
|
{
|
|
bt_tj.Visible = true;
|
|
|
|
}
|
|
if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "删除个人") && jsr.Text == user.zhanghao)
|
|
{
|
|
shanchu.Visible = true;
|
|
}
|
|
if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "删除全部"))
|
|
{
|
|
shanchu.Visible = true;
|
|
bt_shanchu.Visible = true;
|
|
}
|
|
if (DBHlper.GetPermission(juese, "产品档案", "nr_z_cpkc", "添加"))
|
|
{
|
|
//bt_add.Visible = true;
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
#region 加载水彩信息
|
|
/* private void getscyl()
|
|
{
|
|
//加载前段工价
|
|
string getgjsql = "select * from view_nr_z_cpkc_scyl where cpid='" + id.Value + "'";
|
|
string cltable = "<table class='bule'>" +
|
|
"<tr id='0' class='tbtilt'> <td><span>水彩用料</span></td><td><span>用量</span></td><td><span>备注</span></td><td><span>水彩用料</span></td><td><span>用量</span></td><td><span>备注</span></td><td><span>水彩用料</span></td><td><span>用量</span></td><td><span>备注</span></td></tr>";
|
|
DataSet ds = DBHlper.Execute(getgjsql);
|
|
if (ds != null && ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
int sjint = 0;
|
|
int hcount = 1;
|
|
foreach (DataRow r in ds.Tables[0].Rows)
|
|
{
|
|
if (sjint == 0)
|
|
{
|
|
cltable += "<tr>";
|
|
}
|
|
sjint = sjint + 1;
|
|
cltable += " <td><span>" + r["wlmc"].ToString() + "</span></td><td><span>" + Convert.ToDouble(r["scyl"]).ToString() + "</span></td><td><span>" + r["beizhu"].ToString() + "</span></td>";
|
|
if (sjint == 3)
|
|
{
|
|
cltable += "</tr>";
|
|
}
|
|
hcount = hcount + 1;
|
|
}
|
|
if (3 - sjint > 0)
|
|
{
|
|
for (int hz = 0; hz < 3 - sjint; hz++)
|
|
{
|
|
cltable += " <td> </td><td> </td><td> </td>";
|
|
}
|
|
cltable += "</tr>";
|
|
}
|
|
|
|
}
|
|
cltable += "</table>";
|
|
scylxxdiv.InnerHtml = cltable;
|
|
|
|
}*/
|
|
#endregion
|
|
protected void Shanchu_Click(object sender, EventArgs e)
|
|
{
|
|
if (DBHlper.ExecuteReid("select count(*) from view_nr_z_cpkc where id="+id.Value+" and sl>0") > 0) {
|
|
z_error.Text = "产品已有库存,不能删除";
|
|
return;
|
|
}
|
|
|
|
cpkcmodel = cpkcbll.GetModel(Convert.ToInt32(id.Value));
|
|
cpkcmodel.zt = 0;
|
|
bool ci = cpkcbll.Update(cpkcmodel);
|
|
|
|
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 + "删除了产品档案,产品档案号为:" + cpbh.Text.Trim();
|
|
rizhi.yonghuming = zh.zhanghao.ToString();
|
|
rizhibll.Add(rizhi);
|
|
Response.Redirect("Product_list.aspx", false);
|
|
}
|
|
else
|
|
{
|
|
Response.Write("<script>alert('删除失败')</script>");
|
|
}
|
|
}
|
|
protected void wj_Click(object sender, EventArgs e)
|
|
{
|
|
DataSet ds = DBHlper.Execute("select wj from view_nr_z_cpkc where id='" + id.Value + "'");
|
|
string filenams = ds.Tables[0].Rows[0]["wj"].ToString();
|
|
if (filenams != "" && filenams != null)
|
|
{
|
|
string f5 = filenams;
|
|
string fileName = f5;//客户端保存的文件名
|
|
string filePath = Server.MapPath("~/Client_Folder/" + f5);//路径
|
|
FileStream fs = new FileStream(filePath, FileMode.Open);
|
|
byte[] bytes = new byte[(int)fs.Length];
|
|
fs.Read(bytes, 0, bytes.Length);
|
|
fs.Close();
|
|
Response.ContentType = "application/octet-stream";
|
|
//通知浏览器下载文件而不是打开
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
Response.BinaryWrite(bytes);
|
|
Response.Flush();
|
|
Response.End();
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
Response.Write("<script Language='javascript'>alert('没有文件!');window.location.href='Product_browse.aspx?uid=" + id.Value + "'</script>");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|