You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
294 lines
12 KiB
C#
294 lines
12 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
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.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
using System.Text;
|
|
using JsonHelper;
|
|
using DSWeb.Models;
|
|
using DSWeb.EntityDA;
|
|
using DSWeb.Log;
|
|
using DSWeb.Authority;
|
|
|
|
|
|
namespace DSWeb.ParameterSet
|
|
{
|
|
public partial class CodeWmsStorageAreaSet : PageBase
|
|
{
|
|
private string strUserID;//用户GID
|
|
private string strCompanyID;//公司GID
|
|
private string strShowName;//用户显示名
|
|
private string strDeptName;//部门名称
|
|
|
|
public string strHandleType = String.Empty;
|
|
public string sSQL = String.Empty;
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
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 (Session["SHOWNAME"] != null)
|
|
{
|
|
strShowName = Session["SHOWNAME"].ToString();
|
|
}
|
|
if (Session["COMPANYID"] != null)
|
|
{
|
|
strCompanyID = Session["COMPANYID"].ToString();
|
|
}
|
|
if (Session["DEPTNAME"] != null)
|
|
{
|
|
strDeptName = Session["DEPTNAME"].ToString();
|
|
}
|
|
//
|
|
if (!IsPostBack)
|
|
{
|
|
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 wms_storage_area where Gid='" + ViewState["GID"].ToString().Trim() + "'");
|
|
//
|
|
ibDel.Enabled = true;
|
|
ibAdd.Enabled = true;
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
}
|
|
}
|
|
//加载下拉框
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initComboSTORAGENAME();</script>");
|
|
}
|
|
protected void getClear()
|
|
{
|
|
this.hd_comboSTORAGENAME.Value = "";
|
|
tbAREACODE.Text = "";
|
|
tbAREANAME.Text = "";
|
|
tbACREAGE.Text = "";
|
|
cbISENABLE.Checked = false;
|
|
}
|
|
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_comboSTORAGENAME.Value = ds.Tables[0].Rows[0]["STORAGENAME"].ToString().Trim();
|
|
//
|
|
tbAREACODE.Text = ds.Tables[0].Rows[0]["AREACODE"].ToString().Trim();
|
|
tbAREANAME.Text = ds.Tables[0].Rows[0]["AREANAME"].ToString().Trim();
|
|
tbACREAGE.Text = ds.Tables[0].Rows[0]["ACREAGE"].ToString().Trim();
|
|
cbISENABLE.Checked = false;
|
|
if (ds.Tables[0].Rows[0]["ISENABLE"].ToString().Trim().Equals("True"))
|
|
{
|
|
cbISENABLE.Checked = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
getClear();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
getClear();
|
|
}
|
|
}
|
|
protected bool getAdd()
|
|
{
|
|
ViewState["GID"] = Guid.NewGuid().ToString();
|
|
this.hdGid.Value = ViewState["GID"].ToString().Trim();
|
|
sSQL = "insert into wms_storage_area(GID,STORAGENAME,AREACODE,AREANAME,ACREAGE,ISENABLE,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME) values('" + ViewState["GID"].ToString().Trim() + "','" + this.hd_comboSTORAGENAME.Value.Trim() + "','" + tbAREACODE.Text.Trim() + "','" + tbAREANAME.Text.Trim() + "','" + tbACREAGE.Text.Trim() + "','" + cbISENABLE.Checked + "','" + strUserID.Trim() + "',getdate(),'" + strUserID.Trim() + "',getdate())";
|
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
|
|
if (bl)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
protected bool getEdit()
|
|
{
|
|
sSQL = "update wms_storage_area set STORAGENAME='" + this.hd_comboSTORAGENAME.Value.Trim() + "',AREACODE='" + tbAREACODE.Text.Trim() + "',AREANAME='" + tbAREANAME.Text.Trim() + "',ACREAGE='" + tbACREAGE.Text.Trim() + "',ISENABLE='" + cbISENABLE.Checked + "',MODIFIEDUSER='" + strUserID.Trim() + "',MODIFIEDTIME=getdate() where GID='" + ViewState["GID"].ToString().Trim() + "'";
|
|
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
|
|
if (bl)
|
|
{
|
|
ViewState["strHandleType"] = "edit";
|
|
this.hdHandleType.Value = "edit";
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
protected void ibAdd_Click(object sender, EventArgs e)
|
|
{
|
|
ViewState["strHandleType"] = "add";
|
|
this.hdHandleType.Value = "add";
|
|
ViewState["GID"] = Guid.NewGuid().ToString();
|
|
this.hdGid.Value = ViewState["GID"].ToString().Trim();
|
|
getClear();
|
|
//
|
|
ibDel.Enabled = false;
|
|
ibAdd.Enabled = false;
|
|
}
|
|
protected void ibDel_Click(object sender, EventArgs e)
|
|
{
|
|
string strls = T_ALL_DA.GetStrSQL("AREANAME", "select [AREANAME] from wms_storage_area where GID='" + ViewState["GID"].ToString().Trim() + "'");
|
|
if (strls.Trim() != tbAREANAME.Text.Trim())
|
|
{
|
|
strls = T_ALL_DA.GetStrSQL("AREANAME", "select AREANAME from wms_in where AREANAME='" + strls.Trim() + "'");
|
|
if (strls.Trim() != "")
|
|
{
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('库位名称已经启用,因此不允许删除!');</script>");
|
|
return;
|
|
}
|
|
strls = T_ALL_DA.GetStrSQL("AREANAME", "select AREANAME from wms_out_detail where AREANAME='" + strls.Trim() + "'");
|
|
if (strls.Trim() != "")
|
|
{
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('库位名称已经启用,因此不允许删除!');</script>");
|
|
return;
|
|
}
|
|
}
|
|
//
|
|
bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from wms_storage_area where GID='" + ViewState["GID"].ToString().Trim() + "'");
|
|
if (bl)
|
|
{
|
|
ViewState["strHandleType"] = "edit";
|
|
this.hdHandleType.Value = "edit";
|
|
getDataSet("select top 1 * from wms_storage_area order by AREANAME");
|
|
//
|
|
ibDel.Enabled = true;
|
|
ibAdd.Enabled = true;
|
|
//
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','del');</script>");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
ibDel.Enabled = true;
|
|
ibAdd.Enabled = true;
|
|
Response.Write("<script>alert('删除出错!');</script>");
|
|
return;
|
|
}
|
|
}
|
|
|
|
protected void ibEnter_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
string strls = "";
|
|
bool bl = false;
|
|
strHandleType = ViewState["strHandleType"].ToString();
|
|
if (strHandleType.Equals("add"))//新增
|
|
{
|
|
//
|
|
strls = T_ALL_DA.GetStrSQL("AREACODE", "select AREACODE from wms_storage_area where AREACODE='" + tbAREACODE.Text.Trim() + "'");
|
|
if (strls.Trim() != "")
|
|
{
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('代码不允许重复!');</script>");
|
|
return;
|
|
}
|
|
//
|
|
strls = T_ALL_DA.GetStrSQL("AREANAME", "select [AREANAME] from wms_storage_area where [AREANAME]='" + tbAREANAME.Text.Trim() + "'");
|
|
if (strls.Trim() != "")
|
|
{
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('名称不允许重复!');</script>");
|
|
return;
|
|
}
|
|
//
|
|
bl = getAdd();
|
|
}
|
|
else if (strHandleType.Equals("edit"))//录入
|
|
{
|
|
//
|
|
strls = T_ALL_DA.GetStrSQL("AREACODE", "select AREACODE from wms_storage_area where AREACODE='" + tbAREACODE.Text.Trim() + "' and GID<>'" + ViewState["GID"].ToString().Trim() + "'");
|
|
if (strls.Trim() != "")
|
|
{
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('库位代码不允许重复!');</script>");
|
|
return;
|
|
}
|
|
//
|
|
strls = T_ALL_DA.GetStrSQL("AREANAME", "select [AREANAME] from wms_storage_area where [AREANAME]='" + tbAREANAME.Text.Trim() + "' and GID<>'" + ViewState["GID"].ToString().Trim() + "'");
|
|
if (strls.Trim() != "")
|
|
{
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key4", "<script>alert('库位名称不允许重复!');</script>");
|
|
return;
|
|
}
|
|
//
|
|
strls = T_ALL_DA.GetStrSQL("AREANAME", "select [AREANAME] from wms_storage_area where GID='" + ViewState["GID"].ToString().Trim() + "'");
|
|
if (strls.Trim() != tbAREANAME.Text.Trim())
|
|
{
|
|
strls = T_ALL_DA.GetStrSQL("AREANAME", "select AREANAME from wms_in where AREANAME='" + strls.Trim() + "'");
|
|
if (strls.Trim() != "")
|
|
{
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('库位名称已经启用,因此不允许修改!');</script>");
|
|
return;
|
|
}
|
|
strls = T_ALL_DA.GetStrSQL("AREANAME", "select AREANAME from wms_out_detail where AREANAME='" + strls.Trim() + "'");
|
|
if (strls.Trim() != "")
|
|
{
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key5", "<script>alert('库位名称已经启用,因此不允许修改!');</script>");
|
|
return;
|
|
}
|
|
}
|
|
//
|
|
bl = getEdit();
|
|
}
|
|
//
|
|
if (bl)
|
|
{
|
|
//
|
|
ibDel.Enabled = true;
|
|
ibAdd.Enabled = true;
|
|
//
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key6", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','" + strHandleType.Trim() + "');</script>");
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
Response.Write("<script>alert('出错,请重新填写!');</script>");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|