779 lines
29 KiB
C#
779 lines
29 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Ajax;
|
|
using System.Data;
|
|
using System.Collections;
|
|
using System.Text;
|
|
using System.Data.OleDb;
|
|
using System.Text.RegularExpressions;
|
|
using System.IO;
|
|
public partial class Materiel_list : 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();
|
|
int jsid = 0;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
if (Session["user"] == null)
|
|
{
|
|
Response.Redirect("../index.aspx");
|
|
}
|
|
|
|
}
|
|
Utility.RegisterTypeForAjax(typeof(Materiel_list));
|
|
Maticsoft.Model.nr_z_yhzh user = (Maticsoft.Model.nr_z_yhzh)(Session["user"]);
|
|
hiddenid.Value = user.juese.ToString();
|
|
Hiddenname.Value = user.zhanghao;
|
|
jsid = user.juese;
|
|
pdquanxian(jsid);
|
|
}
|
|
#region 数据加载输出
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public string page_change(int pg, int pageitem, string paixu, string tiaojian)
|
|
{
|
|
bool isyincang= tiaojian.Contains("客户纸库");
|
|
Maticsoft.Model.nr_z_yhzh zhanghao = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
string htmlcode = "";
|
|
string paixuselct = "";
|
|
if (isyincang)
|
|
{
|
|
paixuselct = string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ", zhanghao.id, "view_nr_z_wuliao", 1);
|
|
}
|
|
else {
|
|
paixuselct = string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and lieming!='kh_bh' and isxianshi={2} order by shuixu ", zhanghao.id, "view_nr_z_wuliao", 1);
|
|
}
|
|
|
|
|
|
DataTable dtselect = DBHlper.Execute(paixuselct).Tables[0];
|
|
if (dtselect.Rows.Count > 0)
|
|
{
|
|
string wherecode = string.Format("select top {0} ", pageitem);
|
|
foreach (DataRow dtr in dtselect.Rows)
|
|
{
|
|
wherecode += dtr["lieming"] + ",";
|
|
}
|
|
wherecode += "id";
|
|
wherecode += string.Format(" from view_nr_z_wuliao where " + tiaojian + " id not in(select top ({0}*{1}) id from view_nr_z_wuliao "+" where "+tiaojian+" 1=1 " + paixu + ")" + paixu, pg, pageitem);
|
|
DataTable dt_paixu = DBHlper.Execute(wherecode).Tables[0];
|
|
if (dt_paixu.Rows.Count == 0)
|
|
{
|
|
return "<tr><td>   没有数据</td></tr>";
|
|
}
|
|
|
|
for (int i = 0; i < dt_paixu.Rows.Count; i++)
|
|
{
|
|
|
|
htmlcode += "<tr tag='" + dt_paixu.Rows[i]["id"] + "' >";
|
|
htmlcode += " <td style='width:20px'><input type='checkbox' class='xz'/></td>";
|
|
for (int j = 0; j < dt_paixu.Columns.Count - 1; j++)
|
|
{
|
|
|
|
htmlcode += "<td><span>" + dt_paixu.Rows[i][j] + "</span></td>";
|
|
|
|
|
|
}
|
|
htmlcode += "</tr>";
|
|
}
|
|
return htmlcode;
|
|
}
|
|
else
|
|
{
|
|
string lieselect = string.Format("select * from nr_sys_lieming where tblname='{0}' ORDER BY xh", "view_nr_z_wuliao");
|
|
DataTable liedt = DBHlper.Execute(lieselect).Tables[0];
|
|
int lieshuixu = 0;
|
|
foreach (DataRow liedr in liedt.Rows)
|
|
{
|
|
lieshuixu++;
|
|
string cmdinsert = string.Format("insert into nr_lt_paixu values('{0}','{1}','{2}','{3}',{4},{5})", zhanghao.id, "view_nr_z_wuliao", liedr["ywlieming"], liedr["zwlieming"], lieshuixu, 1);
|
|
DBHlper.excutecmd(cmdinsert);
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 传入条数返回页数以便前台调用
|
|
[Ajax.AjaxMethod]
|
|
public int maxpage(int count, string tj)
|
|
{
|
|
int fanhuizhi = 0;
|
|
string cmd = string.Format("select count(*) from view_nr_z_wuliao " + tj);
|
|
int sumcount = DBHlper.getcount(cmd);
|
|
if (sumcount > count)
|
|
{
|
|
fanhuizhi = sumcount / count;
|
|
}
|
|
return fanhuizhi;
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 数据排序
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public void itempaixu(string code)
|
|
{
|
|
Maticsoft.Model.nr_z_yhzh yhzh = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
string[] pxzu = code.Split(';');
|
|
string[] codezu = new string[4];
|
|
foreach (string px in pxzu)
|
|
{
|
|
codezu = px.Split('/');
|
|
string cmdexits = string.Format("select id from nr_lt_paixu where userid='{0}' and tblname='{1}' and lieming='{2}'", yhzh.id, "view_nr_z_wuliao", codezu[2]);
|
|
DataTable paixutable = DBHlper.Execute(cmdexits).Tables[0];
|
|
if (paixutable.Rows.Count > 0)
|
|
{
|
|
int idfanhui = Convert.ToInt32(paixutable.Rows[0][0]);
|
|
string updatepaixu = string.Format("update nr_lt_paixu set shuixu={0},isxianshi={1} where id={2}", codezu[0], codezu[3], idfanhui);
|
|
DBHlper.excutecmd(updatepaixu);
|
|
|
|
}
|
|
else
|
|
{
|
|
string paixuinsert = string.Format("insert into nr_paixu (userid,tblname,lieming,zhongwen,shuixu,isxianshi) values('{0}','{1}','{2}','{3}',{4},{5})", yhzh.id, "view_nr_z_wuliao", codezu[2], codezu[1], codezu[0], codezu[3]);
|
|
DBHlper.excutecmd(paixuinsert);
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 列头排序
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public string paixu()
|
|
{
|
|
Maticsoft.Model.nr_z_yhzh zhanghao = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
string paixuselct = string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ", zhanghao.id, "view_nr_z_wuliao", 1);
|
|
DataTable dtselect = DBHlper.Execute(paixuselct).Tables[0];
|
|
string htmlcode = "<td style='width:20px'><input onclick='selectall()' title='全选' type='checkbox' style='width:20px' id='cbo_selectall'/></td>";
|
|
foreach (DataRow dr in dtselect.Rows)
|
|
{
|
|
if ((dr["lieming"]).ToString() == "kh_bh")
|
|
{
|
|
htmlcode += string.Format("<td class='kh' style='display:none' tag='{0}'>{1}</td>", dr["lieming"], dr["zhongwen"]);
|
|
}
|
|
else {
|
|
htmlcode += string.Format("<td tag='{0}'>{1}</td>", dr["lieming"], dr["zhongwen"]);
|
|
}
|
|
}
|
|
return htmlcode;
|
|
}
|
|
#endregion
|
|
|
|
#region 获取隐藏的列
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public string yincanglie(int endid)
|
|
{
|
|
Maticsoft.Model.nr_z_yhzh zhanghao = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
endid = endid - 1;
|
|
string displaycmd = "select * from nr_lt_paixu where isxianshi=0 and tblname='view_nr_z_wuliao' and userid='" + zhanghao.id + "'";
|
|
DataTable distable = DBHlper.Execute(displaycmd).Tables[0];
|
|
string htmlcode = "";
|
|
foreach (DataRow dr in distable.Rows)
|
|
{
|
|
endid++;
|
|
htmlcode += "<tr class='tr_item' id='tr_" + endid + "'><td style='width:30%'>" + endid + "</td><td style='width:30%' tag=" + dr["lieming"] + ">" + dr["zhongwen"] + "</td><td style='width:30%'><input type='checkbox'/></td> </tr>";
|
|
}
|
|
return htmlcode;
|
|
}
|
|
#endregion
|
|
|
|
#region 查询数据总数
|
|
[Ajax.AjaxMethod]
|
|
public int sumitem(string wheretj)
|
|
{
|
|
string cmd=string.Format("select count(*) from view_nr_z_wuliao " + wheretj);
|
|
int sumcount = DBHlper.getcount(cmd);
|
|
return sumcount;
|
|
}
|
|
#endregion
|
|
|
|
#region 批量删除
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public void piliangshan(int id)
|
|
{
|
|
wuliaomd = wuliaobll.GetModel(id);
|
|
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 + "删除了物料档案,档案编号为:" +wuliaomd.wlbh.ToString() ;
|
|
rizhi.yonghuming = zh.zhanghao.ToString();
|
|
rizhibll.Add(rizhi);
|
|
Response.Redirect("Materiel_list.aspx", false);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 日期查询
|
|
[Ajax.AjaxMethod]
|
|
public string nowdaycount(string option, int selmonth)
|
|
{
|
|
DateTime nowdt = DateTime.Now;
|
|
int days = DateTime.DaysInMonth(nowdt.Year, selmonth);
|
|
string yuechu = nowdt.Year + "-" + selmonth + "-" + "1";
|
|
string yuemo = Convert.ToDateTime(nowdt.Year + "-" + selmonth + "-" +days).AddDays(1).ToString("yyyy-MM-dd");
|
|
DateTime yc = Convert.ToDateTime(yuechu);
|
|
string cmd = "";
|
|
if (option == "")
|
|
{
|
|
cmd = string.Format("select CONVERT(varchar(12),riqi,111) as 'riqi' from view_nr_z_wuliao where riqi>='{0}' and riqi<='{1}' ", yuechu, yuemo);
|
|
}
|
|
else {
|
|
cmd = string.Format("select CONVERT(varchar(12),riqi,111) as 'riqi' from view_nr_z_wuliao where riqi>='{0}' and riqi<='{1}' and kufang='" + option + "'", yuechu, yuemo);
|
|
}
|
|
DataTable dt = DBHlper.Execute(cmd).Tables[0];
|
|
|
|
var biao = "<table class='lbrilitb' id='tbl_yueli'>"
|
|
+ "<tr class='lbrilitbtou'><td width='50px' ><span>日期</span><div><span class='cursor' onclick='yl_up()' title='上月'><</span> <span id='yl_nowmonth' title='" + selmonth + "月'>" + selmonth + "</span> <span class='cursor' onclick='yl_next()' title='下月'>></span></div></td>";
|
|
for (var x = 1; x <= days; x++)
|
|
{
|
|
biao += "<td width='50px'>" + x + "</td>";
|
|
}
|
|
biao += "</tr><tr style='width:100%;height:37px;cursor:pointer'><td width='50px' id='td_sum' onclick='selectallday()' title='全部'>数量</td>";
|
|
for (var x = 1; x <= days; x++)
|
|
{
|
|
string str = yc.ToShortDateString();
|
|
int lenth = dt.Select("riqi='" + yc.ToShortDateString() + "'").Length;
|
|
string everday = yc.Year.ToString();
|
|
if (yc.Month < 10)
|
|
{
|
|
everday += "/0" + yc.Month;
|
|
}
|
|
else
|
|
{
|
|
everday += "/" + yc.Month;
|
|
}
|
|
if (yc.Day < 10)
|
|
{
|
|
everday += "/0" + yc.Day;
|
|
}
|
|
else
|
|
{
|
|
everday += "/" + yc.Day;
|
|
}
|
|
|
|
biao += "<td width='50px' onclick='selectnowday(this)' tag='" + everday + "'>" + dt.Select("riqi='" + everday + "'").Length + "</td>";
|
|
yc = yc.AddDays(1);
|
|
}
|
|
biao += "</tr></table>";
|
|
return biao;
|
|
}
|
|
#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", "查看全部"))
|
|
{
|
|
Response.Redirect("../Common/nopower.htm");
|
|
}
|
|
if (DBHlper.GetPermission(juese, "物料档案", "nr_z_wuliao", "添加") )
|
|
{
|
|
li_add.Visible = true;
|
|
}
|
|
if (DBHlper.GetPermission(juese, "物料档案", "nr_z_wuliao", "删除") )
|
|
{
|
|
li_deleteall.Visible = true;
|
|
}
|
|
if (DBHlper.GetPermission(juese, "物料档案", "nr_z_wuliao", "导出") )
|
|
{
|
|
xiazai.Visible = true ;
|
|
}
|
|
if (DBHlper.GetPermission(juese, "物料档案", "nr_z_wuliao", "导入") )
|
|
{
|
|
daoru.Visible = true;
|
|
}
|
|
if (DBHlper.GetPermission(juese, "物料档案", "nr_z_wuliao", "配置") )
|
|
{
|
|
leiset.Visible = true;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 判断查看权限
|
|
[Ajax.AjaxMethod]
|
|
public string isquanxian(int uid)
|
|
{
|
|
|
|
if (DBHlper.GetPermission(uid, "物料档案", "nr_z_wuliao", "查看全部"))
|
|
{
|
|
return "1";
|
|
}
|
|
else{
|
|
return "";
|
|
}
|
|
}
|
|
#endregion
|
|
#region 下载方法
|
|
public void DownLoad(object o, EventArgs e)
|
|
{
|
|
Maticsoft.Model.nr_z_yhzh zhanghao = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
string selectid = this.selectid.Value;
|
|
string colmn = "";
|
|
ArrayList sList = new ArrayList();
|
|
DataTable dtcolmnname = DBHlper.Execute("select lieming,zhongwen from nr_lt_paixu where tblname='view_nr_z_wuliao' and isxianshi=1 and userid='" + ((Maticsoft.Model.nr_z_yhzh)Session["user"]).id + "' order by shuixu").Tables[0];
|
|
string tj = strwhere.Value;
|
|
string selzt=drp_zt.SelectedItem.Value;
|
|
foreach (DataRow r in dtcolmnname.Rows)
|
|
{
|
|
if (r["lieming"].ToString() == "kh_bh")
|
|
{
|
|
if (selzt == "客户纸库")
|
|
{
|
|
colmn += r["lieming"].ToString() + ',';
|
|
sList.Add(r["zhongwen"].ToString());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
colmn += r["lieming"].ToString() + ',';
|
|
sList.Add(r["zhongwen"].ToString());
|
|
}
|
|
}
|
|
colmn = colmn.TrimEnd(',');
|
|
string selectcode = "";
|
|
if ( selzt== "主料库")
|
|
{
|
|
selectcode = "select " + colmn + " from view_nr_z_wuliao where zt='1' and kufang='主料库' ";
|
|
}
|
|
else if (selzt == "辅料库")
|
|
{
|
|
selectcode = "select " + colmn + " from view_nr_z_wuliao where zt='1' and kufang='辅料库' ";
|
|
}
|
|
else if (selzt == "客户纸库")
|
|
{
|
|
selectcode = "select " + colmn + " from view_nr_z_wuliao where zt='1' and kufang='客户纸库' ";
|
|
}
|
|
else if(selzt=="") {
|
|
selectcode = "select " + colmn + " from view_nr_z_wuliao where zt='1' ";
|
|
}
|
|
if (tj != "")
|
|
{
|
|
selectcode += tj.Replace("where", "and");
|
|
}
|
|
if (selectid != "")
|
|
{
|
|
selectcode += " and id in(" + selectid.TrimEnd(',') + ")";
|
|
}
|
|
DataTable dt = DBHlper.Execute(selectcode + " order by id desc").Tables[0];
|
|
DBHlper.ExportByWeb(dt, "物料"+DateTime.Now, sList);
|
|
}
|
|
#endregion
|
|
string zhonglei = "";
|
|
protected void btn_daoru(object o, EventArgs e)
|
|
{
|
|
string strFileFullName = file_lujing.PostedFile.FileName;
|
|
string strExcCaps = System.IO.Path.GetExtension(strFileFullName).ToLower();
|
|
if (strExcCaps != ".xls" && strExcCaps != ".xlsx")
|
|
{
|
|
lbl_zerror.Text = "您只能上传后缀名为.xls和.xlsx格式的文件";
|
|
return;
|
|
}
|
|
string filelujing = Server.MapPath("~/Excel/");
|
|
string strPath = filelujing + file_lujing.FileName;
|
|
file_lujing.PostedFile.SaveAs(strPath);
|
|
try
|
|
{
|
|
string mystring = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source = '" + strPath + "';Extended Properties=Excel 12.0 ;";
|
|
OleDbConnection cnnxls = new OleDbConnection(mystring);
|
|
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [Sheet1$]", cnnxls);
|
|
DataSet myDs = new DataSet();
|
|
myDa.Fill(myDs);
|
|
DataTable dt = myDs.Tables[0];
|
|
int djcount = 0;
|
|
foreach (DataColumn dclmn in dt.Columns)
|
|
{
|
|
if (dclmn.ColumnName == "单价")
|
|
{
|
|
djcount++;
|
|
}
|
|
}
|
|
if (djcount > 0)
|
|
{
|
|
dt.Columns.Remove("单价");
|
|
}
|
|
string errortishi = "";
|
|
int i = 1;
|
|
List<string> listhead = new List<string>();
|
|
string columnname = "";
|
|
string where = "";
|
|
string wherecode = "insert into nr_z_wuliao (";
|
|
int wlbhindex = 0;
|
|
int ckindex = 0;
|
|
int guigeindex = 0;
|
|
int pinpaiindex = 0;
|
|
for (int j = 0; j < dt.Columns.Count; j++)
|
|
{
|
|
columnname = dt.Columns[j].ColumnName;
|
|
if (columnname == "物料编号")
|
|
{
|
|
listhead.Add("wlbh");
|
|
wherecode += "wlbh,";
|
|
wlbhindex = j;
|
|
}
|
|
else if (columnname == "名称")
|
|
{
|
|
listhead.Add("mingcheng");
|
|
wherecode += "mingcheng,";
|
|
}
|
|
else if (columnname == "种类")
|
|
{
|
|
listhead.Add("zhonglei");
|
|
wherecode += "zhonglei,";
|
|
}
|
|
else if (columnname == "品牌")
|
|
{
|
|
listhead.Add("pinpai");
|
|
wherecode += "pinpai,";
|
|
pinpaiindex = j;
|
|
}
|
|
else if (columnname == "长度")
|
|
{
|
|
listhead.Add("changdu");
|
|
wherecode += "changdu,";
|
|
}
|
|
else if (columnname == "规格")
|
|
{
|
|
listhead.Add("guige");
|
|
wherecode += "guige,";
|
|
guigeindex = j;
|
|
}
|
|
else if (columnname == "宽度")
|
|
{
|
|
listhead.Add("kuandu");
|
|
wherecode += "kuandu,";
|
|
}
|
|
else if (columnname == "单位")
|
|
{
|
|
listhead.Add("danwei");
|
|
wherecode += "danwei,";
|
|
}
|
|
else if (columnname == "仓库")
|
|
{
|
|
listhead.Add("kufang");
|
|
wherecode += "kufang,";
|
|
ckindex = j;
|
|
}
|
|
else if (columnname == "客户编号")
|
|
{
|
|
listhead.Add("kh_bh");
|
|
wherecode += "kh_bh,";
|
|
}
|
|
else if (columnname == "最低库存")
|
|
{
|
|
listhead.Add("zuidkucun");
|
|
wherecode += "zuidkucun,";
|
|
}
|
|
else if (columnname == "最高库存")
|
|
{
|
|
listhead.Add("zuigkucun");
|
|
wherecode += "zuigkucun,";
|
|
}
|
|
else if (columnname == "库存")
|
|
{
|
|
listhead.Add("kucun");
|
|
wherecode += "kucun,";
|
|
}
|
|
else if (columnname == "报价")
|
|
{
|
|
listhead.Add("baojia");
|
|
wherecode += "baojia,";
|
|
}
|
|
else if (columnname == "备注")
|
|
{
|
|
listhead.Add("beizhu");
|
|
wherecode += "beizhu,";
|
|
}
|
|
else if (columnname == "日期")
|
|
{
|
|
listhead.Add("riqi");
|
|
wherecode += "riqi,";
|
|
}
|
|
else if (columnname == "金额")
|
|
{
|
|
listhead.Add("jine");
|
|
wherecode += "jine,";
|
|
}
|
|
wherecode.TrimEnd(',');
|
|
}
|
|
wherecode = wherecode.TrimEnd(',');
|
|
wherecode += ") values(";
|
|
where = wherecode;
|
|
int wlcount = 0;
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
wlcount = DBHlper.getcount(string.Format("select count(*) from view_nr_z_wuliao where wlbh='{0}' and kufang='{1}' and guige='{2}' and pinpai='{3}'", dr[wlbhindex], dr[ckindex], dr[guigeindex], dr[pinpaiindex]));
|
|
if (wlcount > 0)
|
|
{
|
|
i++;
|
|
continue;
|
|
}
|
|
for (int t = 0; t < listhead.Count; t++)
|
|
{
|
|
columnname = listhead[t];
|
|
if (columnname == "zhonglei")
|
|
{
|
|
testexits(dr[t].ToString());
|
|
if (zhonglei == "")
|
|
{
|
|
errortishi = "第" + i + "行没有此种类";
|
|
gongjuzhankai(errortishi);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
wherecode += zhonglei + ",";
|
|
}
|
|
}
|
|
else if (columnname == "changdu")
|
|
{
|
|
if (dr[t] is DBNull)
|
|
{
|
|
wherecode += 0 + ",";
|
|
}
|
|
else if (IsNumeric(dr[t]))
|
|
{
|
|
wherecode += dr[t] + ",";
|
|
}
|
|
else
|
|
{
|
|
errortishi = "第" + i + "行长度格式不正确";
|
|
gongjuzhankai(errortishi);
|
|
return;
|
|
}
|
|
}
|
|
else if (columnname == "kuandu")
|
|
{
|
|
if (dr[t] is DBNull)
|
|
{
|
|
wherecode += 0 + ",";
|
|
}
|
|
else if (IsNumeric(dr[t]))
|
|
{
|
|
wherecode += dr[t] + ",";
|
|
}
|
|
else
|
|
{
|
|
errortishi = "第" + i + "行宽度格式不正确";
|
|
gongjuzhankai(errortishi);
|
|
return;
|
|
}
|
|
|
|
}
|
|
else if (columnname == "danwei")
|
|
{
|
|
testexits(dr[t].ToString());
|
|
if (zhonglei == "")
|
|
{
|
|
errortishi = "第" + i + "行没有此单位";
|
|
gongjuzhankai(errortishi);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
wherecode += zhonglei + ",";
|
|
}
|
|
}
|
|
//else if (columnname == "kufang")
|
|
//{
|
|
// testexits(dr[t].ToString());
|
|
// if (zhonglei == "")
|
|
// {
|
|
// errortishi = "第" + i + "行没有此库房";
|
|
// gongjuzhankai(errortishi);
|
|
// }
|
|
// else {
|
|
// wherecode += zhonglei + ",";
|
|
// }
|
|
//}
|
|
else if (columnname == "zuidkucun")
|
|
{
|
|
if (dr[t] is DBNull)
|
|
{
|
|
wherecode += 0 + ",";
|
|
}
|
|
else if (IsNumeric(dr[t]))
|
|
{
|
|
wherecode += dr[t] + ",";
|
|
}
|
|
else
|
|
{
|
|
errortishi = "第" + i + "最低库存格式不正确";
|
|
gongjuzhankai(errortishi);
|
|
return;
|
|
}
|
|
}
|
|
else if (columnname == "zuigkucun")
|
|
{
|
|
if (dr[t] is DBNull)
|
|
{
|
|
wherecode += 0 + ",";
|
|
}
|
|
else if (IsNumeric(dr[t]))
|
|
{
|
|
wherecode += dr[t] + ",";
|
|
}
|
|
else
|
|
{
|
|
errortishi = "第" + i + "最高库存格式不正确";
|
|
gongjuzhankai(errortishi);
|
|
return;
|
|
}
|
|
}
|
|
else if (columnname == "kucun")
|
|
{
|
|
if (dr[t] is DBNull)
|
|
{
|
|
wherecode += 0 + ",";
|
|
}
|
|
else if (IsNumeric(dr[t]))
|
|
{
|
|
wherecode += dr[t] + ",";
|
|
}
|
|
else
|
|
{
|
|
errortishi = "第" + i + "库存格式不正确";
|
|
gongjuzhankai(errortishi);
|
|
return;
|
|
}
|
|
|
|
}
|
|
else if (columnname == "baojia")
|
|
{
|
|
if (dr[t] is DBNull)
|
|
{
|
|
wherecode += 0 + ",";
|
|
}
|
|
else if (IsNumeric(dr[t]))
|
|
{
|
|
wherecode += dr[t] + ",";
|
|
}
|
|
else
|
|
{
|
|
errortishi = "第" + i + "报价格式不正确";
|
|
gongjuzhankai(errortishi);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//if (!(dr[wlbhindex] is DBNull))
|
|
//{
|
|
// int count = DBHlper.getcount(string.Format("select count(*) from nr_z_wuliao where wlbh='{0}' and kufang='{1}'", dr[wlbhindex], dr[ckindex]));
|
|
|
|
//}
|
|
|
|
wherecode += " '" + dr[t] + "',";
|
|
}
|
|
// string strcode = string.Format("insert into nr_z_wuliao(mingcheng,zhonglei,pinpai,changdu,kuandu,danwei,kh_bh,kufang,zuidkucun,zuigkucun,kucun,baojia,beizhu,wlbh,riqi) values('{0}','{1}','{2}',{3},{4},'{5}','{6}','{7}',{8},{9},{10},{11,'{12}','{13}','{14}'})", dr[0].ToString(), zhonglei, dr[2].ToString(), dr[3], dr[4], dr[5], dr[6], dr[7], dr[8], dr[9], dr[10], dr[11], dr[12], DBHlper.getbh("WL-", "nr_z_wuliao", "wlbh", 4), DateTime.Now.ToShortDateString());
|
|
|
|
}
|
|
i++;
|
|
wherecode = wherecode.TrimEnd(',') + ')';
|
|
DBHlper.excutecmd(wherecode);
|
|
wherecode = where;
|
|
}
|
|
Response.Redirect("Materiel_list.aspx");
|
|
}
|
|
catch (Exception ex) {
|
|
Response.Write(ex.Message);
|
|
}
|
|
|
|
}
|
|
void gongjuzhankai(string tishi)
|
|
{
|
|
lbl_zerror.Text = tishi;
|
|
Gjx.Style.Add("display", "block");
|
|
div_daoru.Style.Add("display", "block");
|
|
}
|
|
void testexits(string code)
|
|
{
|
|
zhonglei=DBHlper.getfirstcolmn("select id from nr_sys_bianma where mingcheng='" + code.Trim() + "'");
|
|
}
|
|
|
|
|
|
public static bool IsNumeric(object value)
|
|
{
|
|
try
|
|
{
|
|
Convert.ToDecimal(value);
|
|
return true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
#region 汇总
|
|
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.ReadWrite)]
|
|
public string gethuizong(string tiaojian, string[] hzlie)
|
|
{
|
|
Maticsoft.Model.nr_z_yhzh zhanghao = (Maticsoft.Model.nr_z_yhzh)Session["user"];
|
|
string code = "<td></td>";
|
|
bool isyincang = tiaojian.Contains("客户纸库");
|
|
string paixuselct = "";
|
|
if (isyincang)
|
|
{
|
|
paixuselct = string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and isxianshi={2} order by shuixu ", zhanghao.id, "view_nr_z_wuliao", 1);
|
|
}
|
|
else
|
|
{
|
|
paixuselct = string.Format("select * from nr_lt_paixu where userid='{0}' and tblname='{1}' and lieming!='kh_bh' and isxianshi={2} order by shuixu ", zhanghao.id, "view_nr_z_wuliao", 1);
|
|
}
|
|
DataTable dtselect = DBHlper.Execute(paixuselct).Tables[0];
|
|
string datacolmn = "";
|
|
string wherecode = "";
|
|
int exits = 0;
|
|
foreach (DataRow dr in dtselect.Rows)
|
|
{
|
|
exits = 0;
|
|
foreach (string lie in hzlie)
|
|
{
|
|
if (dr["zhongwen"].ToString() == lie)
|
|
{
|
|
exits++;
|
|
}
|
|
}
|
|
if (exits == 0)
|
|
{
|
|
code += "<td></td>";
|
|
}
|
|
else
|
|
{
|
|
datacolmn = dr["lieming"].ToString();
|
|
wherecode = "select sum(" + datacolmn + ") ";
|
|
wherecode += " from view_nr_z_wuliao where " + tiaojian;
|
|
wherecode += " 1=1 ";
|
|
code += "<td class='blue'>" + DBHlper.getfirstcolmn(wherecode) + "</td>";
|
|
}
|
|
}
|
|
return code;
|
|
}
|
|
#endregion
|
|
|
|
} |