|
|
|
|
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 CodeGoodsDetailSetInfo : 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;
|
|
|
|
|
//strUserID = "";
|
|
|
|
|
//hdUserID.Value = strUserID;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
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"://新增
|
|
|
|
|
getClear();
|
|
|
|
|
//
|
|
|
|
|
ibDel.Enabled = false;
|
|
|
|
|
ibAdd.Enabled = false;
|
|
|
|
|
break;
|
|
|
|
|
case "edit"://录入
|
|
|
|
|
getDataSet("select * from code_goods_detail where GID='" + ViewState["GID"].ToString().Trim() + "'");
|
|
|
|
|
//
|
|
|
|
|
ibDel.Enabled = true;
|
|
|
|
|
ibAdd.Enabled = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//加载下拉框
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initComboGOODSNAME();</script>");
|
|
|
|
|
}
|
|
|
|
|
protected void getClear()
|
|
|
|
|
{
|
|
|
|
|
ViewState["strHandleType"] = "add";
|
|
|
|
|
this.hdHandleType.Value = "add";
|
|
|
|
|
ViewState["GID"] = getBSNO();
|
|
|
|
|
this.hdGid.Value = ViewState["GID"].ToString().Trim();
|
|
|
|
|
//this.hd_comboGOODSNAME.Value = "";
|
|
|
|
|
tbGOODSDETAILNAME.Text = "";
|
|
|
|
|
tbREMARK.Text = "";
|
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
this.hd_comboGOODSNAME.Value = T_ALL_DA.GetStrSQL("GOODNAME", "select top 1 GOODNAME from code_goods where GID='" + ds.Tables[0].Rows[0]["LINKGID"].ToString().Trim() + "'");
|
|
|
|
|
tbGOODSDETAILNAME.Text = ds.Tables[0].Rows[0]["GOODSDETAILNAME"].ToString().Trim();
|
|
|
|
|
tbREMARK.Text = ds.Tables[0].Rows[0]["REMARK"].ToString().Trim();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
getClear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
getClear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected String getBSNO()
|
|
|
|
|
{
|
|
|
|
|
string strBSNO = Guid.NewGuid().ToString();
|
|
|
|
|
strBSNO = strBSNO.Replace("-", "");
|
|
|
|
|
strBSNO = "CGD" + strBSNO;
|
|
|
|
|
return strBSNO;
|
|
|
|
|
}
|
|
|
|
|
protected bool getAdd()
|
|
|
|
|
{
|
|
|
|
|
sSQL = "insert into code_goods_detail(GID,LINKGID,GOODSDETAILNAME,REMARK) "
|
|
|
|
|
+ "select top 1 '" + ViewState["GID"].ToString().Trim() + "',GID,'" + tbGOODSDETAILNAME.Text.Trim() + "','" + tbREMARK.Text.Trim() + "' from code_goods where GOODNAME='" + this.hd_comboGOODSNAME.Value.Trim() + "'";
|
|
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
|
|
|
|
|
if (bl)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected bool getEdit()
|
|
|
|
|
{
|
|
|
|
|
sSQL = "update code_goods_detail set LINKGID=(select top 1 GID from code_goods where GOODNAME='" + this.hd_comboGOODSNAME.Value.Trim() + "'),GOODSDETAILNAME='" + tbGOODSDETAILNAME.Text.Trim() + "',REMARK='" + tbREMARK.Text.Trim() + "' where GID='" + ViewState["GID"].ToString().Trim() + "'";
|
|
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
|
|
|
|
|
if (bl)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected void getEnter()
|
|
|
|
|
{
|
|
|
|
|
string strls = "";
|
|
|
|
|
bool bl = false;
|
|
|
|
|
strHandleType = this.hdHandleType.Value.Trim();
|
|
|
|
|
if (strHandleType.Equals("add"))//新增
|
|
|
|
|
{
|
|
|
|
|
strls = T_ALL_DA.GetStrSQL("GOODSDETAILNAME", "select GOODSDETAILNAME from code_goods_detail where LINKGID=(select top 1 GID from code_goods where GOODNAME='" + this.hd_comboGOODSNAME.Value.Trim() + "') and GOODSDETAILNAME='" + tbGOODSDETAILNAME.Text.Trim() + "'");
|
|
|
|
|
if (strls.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('同一品名的品牌不允许重复!');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
bl = getAdd();
|
|
|
|
|
}
|
|
|
|
|
else if (strHandleType.Equals("edit"))//录入
|
|
|
|
|
{
|
|
|
|
|
strls = T_ALL_DA.GetStrSQL("GOODSDETAILNAME", "select GOODSDETAILNAME from code_goods_detail where LINKGID=(select top 1 GID from code_goods where GOODNAME='" + this.hd_comboGOODSNAME.Value.Trim() + "') and GOODSDETAILNAME='" + tbGOODSDETAILNAME.Text.Trim() + "' and GID<>'" + ViewState["GID"].ToString().Trim() + "'");
|
|
|
|
|
if (strls.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('同一品名的品牌不允许重复!');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
bl = getEdit();
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
if (bl)
|
|
|
|
|
{
|
|
|
|
|
//
|
|
|
|
|
ibDel.Enabled = true;
|
|
|
|
|
ibAdd.Enabled = true;
|
|
|
|
|
//
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','" + strHandleType .Trim()+ "');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key6", "<script>alert('出错,请重新填写!');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
protected void ibAdd_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
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_detail where GID='" + ViewState["GID"].ToString().Trim() + "'");
|
|
|
|
|
if (bl)
|
|
|
|
|
{
|
|
|
|
|
ViewState["strHandleType"] = "edit";
|
|
|
|
|
this.hdHandleType.Value = "edit";
|
|
|
|
|
getDataSet("select top 1 * from code_goods_detail ORDER BY GOODSDETAILNAME");
|
|
|
|
|
//
|
|
|
|
|
ibDel.Enabled = true;
|
|
|
|
|
ibAdd.Enabled = true;
|
|
|
|
|
//
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key9", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','del');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ibDel.Enabled = true;
|
|
|
|
|
ibAdd.Enabled = true;
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key8", "<script>alert('删除出错!');</script>");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|