using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Text; using DSWeb.DataAccess; using System.Data.SqlClient; using DSWeb.Models; using DSWeb.EntityDA; using System.Web.Script.Serialization; using System.ComponentModel; using System.Drawing; using System.Web.SessionState; using System.Web.Mail; using System.IO; using System.Data.OleDb; using JsonHelper; using DSWeb.Log; namespace DSWeb.ParameterSet { public partial class CodeGoodsSetInfo : System.Web.UI.Page { public string strHandleType = String.Empty; public string sSQL = String.Empty; T_ALL_DA T_ALL_DA = new T_ALL_DA(); public string strUserID;//用户GID protected void Page_Load(object sender, EventArgs e) { if (Session["USERID"] != null) { strUserID = Session["USERID"].ToString().Trim(); hdUserID.Value = strUserID; } else { Server.Transfer("~/Error/FriendError.aspx"); return; } // if (ViewState["GID"] != null) { if (this.hdEnter.Value != "") { getEnter(); } } // if (!IsPostBack) { if (Request.QueryString["handle"] != null) //if (Request.QueryString["handle"] != null) { ViewState["strHandleType"] = Request.QueryString["handle"].ToString(); this.hdHandleType.Value = Request.QueryString["handle"].ToString(); strHandleType = Request.QueryString["handle"].ToString(); if (Request.QueryString["id"] != null) { ViewState["GID"] = Request.QueryString["id"].ToString(); this.hdGid.Value = ViewState["GID"].ToString().Trim(); } switch (strHandleType) { case "add"://新增 ViewState["GID"] = getBSNO(); this.hdGid.Value = ViewState["GID"].ToString().Trim(); getClear(); // ibDel.Enabled = false; ibAdd.Enabled = false; break; case "edit"://录入 getDataSet("select * from code_goods where GID='" + ViewState["GID"].ToString().Trim() + "'"); // ibDel.Enabled = true; ibAdd.Enabled = true; break; } } else { } } //加载下拉框 Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", ""); } protected void getClear() { tbGOODCODE.Text = ""; tbGOODNAME.Text = ""; tbDESCRIP.Text = ""; tbARRATE.Text = "0.00"; tbAPRATE.Text = "0.00"; tbAROUTRATE.Text = "0.00"; tbAPOUTRATE.Text = "0.00"; cbISSTOP.Checked = false; hd_comboGoodsTypeName.Value = ""; } protected void getDataSet(string str) { DataSet ds = T_ALL_DA.GetAllSQL(str); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { ViewState["GID"] = ds.Tables[0].Rows[0]["GID"].ToString().Trim(); tbGOODCODE.Text = ds.Tables[0].Rows[0]["GOODCODE"].ToString().Trim(); tbGOODNAME.Text = ds.Tables[0].Rows[0]["GOODNAME"].ToString().Trim(); tbDESCRIP.Text = ds.Tables[0].Rows[0]["DESCRIP"].ToString().Trim(); tbARRATE.Text = ds.Tables[0].Rows[0]["ARRATE"].ToString().Trim(); tbAPRATE.Text = ds.Tables[0].Rows[0]["APRATE"].ToString().Trim(); ; tbAROUTRATE.Text = ds.Tables[0].Rows[0]["AROUTRATE"].ToString().Trim(); tbAPOUTRATE.Text = ds.Tables[0].Rows[0]["APOUTRATE"].ToString().Trim(); cbISSTOP.Checked = bool.Parse(ds.Tables[0].Rows[0]["ISSTOP"].ToString().Trim()); string GoodsTypeGID = ds.Tables[0].Rows[0]["GoodsTypeGID"].ToString().Trim(); this.hd_comboGoodsTypeName.Value = T_ALL_DA.GetStrSQL("GoodsTypeName", "select top 1 GoodsTypeName from code_goodsType where gid='" + GoodsTypeGID + "'"); } else { getClear(); } } else { getClear(); } } protected String getBSNO() { string strBSNO = Guid.NewGuid().ToString(); strBSNO = strBSNO.Replace("-", ""); strBSNO = "GOOD" + strBSNO; return strBSNO; } protected bool getAdd() { string GoodsTypeGID = T_ALL_DA.GetStrSQL("GID", "select top 1 GID from code_goodsType where GoodsTypeName='" + this.hd_comboGoodsTypeName.Value.Trim() + "'"); sSQL = "insert into code_goods(GID,GOODCODE,GOODNAME,DESCRIP,ARRATE,APRATE,AROUTRATE,APOUTRATE,ISSTOP,GoodsTypeGID) values('" + ViewState["GID"].ToString().Trim() + "','" + tbGOODCODE.Text.Trim() + "','" + tbGOODNAME.Text.Trim() + "','" + tbDESCRIP.Text.Trim() + "','" + tbARRATE.Text.Trim() + "','" + tbAPRATE.Text.Trim() + "','" + tbAROUTRATE.Text.Trim() + "','" + tbAPOUTRATE.Text.Trim() + "','" + cbISSTOP.Checked + "','" + GoodsTypeGID + "')"; bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL); if (bl) { return true; } else { return false; } } protected bool getEdit() { string GoodsTypeGID = T_ALL_DA.GetStrSQL("GID", "select top 1 GID from code_goodsType where GoodsTypeName='" + this.hd_comboGoodsTypeName.Value.Trim() + "'"); sSQL = "update code_goods set GOODCODE='" + tbGOODCODE.Text.Trim() + "',GOODNAME='" + tbGOODNAME.Text.Trim() + "',DESCRIP='" + tbDESCRIP.Text.Trim() + "',ARRATE='" + tbARRATE.Text.Trim() + "',APRATE='" + tbAPRATE.Text.Trim() + "',AROUTRATE='" + tbAROUTRATE.Text.Trim() + "',APOUTRATE='" + tbAPOUTRATE.Text.Trim() + "',ISSTOP='" + cbISSTOP.Checked + "',GoodsTypeGID='" + GoodsTypeGID + "' where GID='" + ViewState["GID"].ToString().Trim() + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL); if (bl) { return true; } else { return false; } } protected void getEnter() { if (tbGOODCODE.Text.Trim() == "") { Response.Write(""); return; } // string strls = ""; bool bl = false; strHandleType = this.hdHandleType.Value.Trim(); if (strHandleType.Equals("add"))//新增 { strls = T_ALL_DA.GetStrSQL("GOODCODE", "select GOODCODE from code_goods where GOODCODE='" + tbGOODCODE.Text.Trim() + "'"); if (strls.Trim() != "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", ""); return; } // bl = getAdd(); } else if (strHandleType.Equals("edit"))//录入 { strls = T_ALL_DA.GetStrSQL("GOODCODE", "select GOODCODE from code_goods where GOODCODE='" + tbGOODCODE.Text.Trim() + "' and GID<>'" + ViewState["GID"].ToString().Trim() + "'"); if (strls.Trim() != "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", ""); return; } // bl = getEdit(); } // if (bl) { ibDel.Enabled = true; ibAdd.Enabled = true; // Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", ""); return; } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "key6", ""); return; } } protected void ibAdd_Click(object sender, EventArgs e) { ViewState["strHandleType"] = "add"; this.hdHandleType.Value = "add"; ViewState["GID"] = getBSNO(); this.hdGid.Value = ViewState["GID"].ToString().Trim(); getClear(); // ibDel.Enabled = false; ibAdd.Enabled = false; } protected void ibDel_Click(object sender, EventArgs e) { bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from code_goods where GID='" + ViewState["GID"].ToString().Trim() + "'"); if (bl) { ViewState["strHandleType"] = "edit"; this.hdHandleType.Value = "edit"; getDataSet("select top 1 * from code_goods ORDER BY GOODNAME"); // ibDel.Enabled = true; ibAdd.Enabled = true; // Page.ClientScript.RegisterStartupScript(this.GetType(), "key9", ""); return; } else { ibDel.Enabled = true; ibAdd.Enabled = true; Page.ClientScript.RegisterStartupScript(this.GetType(), "key8", ""); return; } } } }