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.

369 lines
16 KiB
C#

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 CodeFeeSetInfo : 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();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
}
//
if (ViewState["GID"] != null)
{
if (this.hdEnter.Value != "")
{
getEnter();
}
}
//
if (!IsPostBack)
{
getFEETYPE();
//
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_fee where Gid='" + ViewState["GID"].ToString().Trim() + "'");
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
break;
}
}
else
{
}
}
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initComboDEFAULTCURR();initComboFEEGROUP();</script>");
}
protected void getClear()
{
this.hd_comboDEFAULTCURR.Value = "";
this.hd_comboFEEGROUP.Value = "";
tbFEECODE.Text="";
tbNAME.Text="";
this.hdNAME.Value = "";
tbDESCRIPTION.Text="";
cbISSEA.Checked=false;
cbISAIR.Checked = false;
cbISTRUCKING.Checked = false;
cbISTRUCKINGFIXED.Checked = false;
cbISWMS.Checked = false;
ddlDEFAULTUNIT.Text="";
ddlDEFAULTDEBIT.Text="";
ddlDEFAULTCREDIT.Text="";
ddlFEETYPE.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_comboDEFAULTCURR.Value = ds.Tables[0].Rows[0]["DEFAULTCURR"].ToString().Trim();
this.hd_comboFEEGROUP.Value = ds.Tables[0].Rows[0]["FEEGROUP"].ToString().Trim();
//
cbISSEA.Checked = false;
cbISAIR.Checked = false;
cbISTRUCKING.Checked = false;
cbISTRUCKINGFIXED.Checked = false;
cbISWMS.Checked = false;
if (ds.Tables[0].Rows[0]["ISSEA"].ToString().Trim().Equals("True"))
{
cbISSEA.Checked = true;
}
if (ds.Tables[0].Rows[0]["ISAIR"].ToString().Trim().Equals("True"))
{
cbISAIR.Checked = true;
}
if (ds.Tables[0].Rows[0]["ISTRUCKING"].ToString().Trim().Equals("True"))
{
cbISTRUCKING.Checked = true;
}
if (ds.Tables[0].Rows[0]["ISTRUCKINGFIXED"].ToString().Trim().Equals("True"))
{
cbISTRUCKINGFIXED.Checked = true;
}
if (ds.Tables[0].Rows[0]["ISWMS"].ToString().Trim().Equals("True"))
{
cbISWMS.Checked = true;
}
//
tbFEECODE.Text = ds.Tables[0].Rows[0]["FEECODE"].ToString().Trim();
tbNAME.Text = ds.Tables[0].Rows[0]["NAME"].ToString().Trim();
this.hdNAME.Value = ds.Tables[0].Rows[0]["NAME"].ToString().Trim();
tbDESCRIPTION.Text = ds.Tables[0].Rows[0]["DESCRIPTION"].ToString().Trim();
ddlDEFAULTUNIT.Text = ds.Tables[0].Rows[0]["DEFAULTUNIT"].ToString().Trim();
ddlDEFAULTDEBIT.Text = ds.Tables[0].Rows[0]["DEFAULTDEBIT"].ToString().Trim();
ddlDEFAULTCREDIT.Text = ds.Tables[0].Rows[0]["DEFAULTCREDIT"].ToString().Trim();
ddlFEETYPE.Text = ds.Tables[0].Rows[0]["FEETYPE"].ToString().Trim();
}
else
{
getClear();
}
}
else
{
getClear();
}
}
protected String getBSNO()
{
string strBSNO = Guid.NewGuid().ToString();
strBSNO = strBSNO.Replace("-", "");
strBSNO = "Cfee" + strBSNO;
return strBSNO;
}
protected bool getAdd()
{
sSQL = "insert into code_fee(GID,FEECODE,[NAME],DESCRIPTION,DEFAULTCURR,ISSEA,ISAIR,ISTRUCKING,ISTRUCKINGFIXED,DEFAULTUNIT,DEFAULTDEBIT,DEFAULTCREDIT,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,FEETYPE,ISWMS,FEEGROUP) values('" + ViewState["GID"].ToString().Trim() + "','" + tbFEECODE.Text.Trim() + "','" + this.hdNAME.Value.Trim() + "','" + tbDESCRIPTION.Text.Trim() + "','" + this.hd_comboDEFAULTCURR.Value.Trim() + "','" + cbISSEA.Checked + "','" + cbISAIR.Checked + "','" + cbISTRUCKING.Checked + "','" + cbISTRUCKINGFIXED.Checked + "','" + ddlDEFAULTUNIT.Text.Trim() + "','" + ddlDEFAULTDEBIT.Text.Trim() + "','" + ddlDEFAULTCREDIT.Text.Trim() + "','" + strUserID.Trim() + "',getdate(),'" + strUserID.Trim() + "',getdate(),'" + ddlFEETYPE.Text.Trim() + "','" + cbISWMS.Checked + "','" + this.hd_comboFEEGROUP.Value.Trim() + "')";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
if (bl)
{
return true;
}
else
{
return false;
}
}
protected bool getEdit()
{
sSQL = "update code_fee set FEECODE='" + tbFEECODE.Text.Trim() + "',[NAME]='" + this.hdNAME.Value.Trim() + "',DESCRIPTION='" + tbDESCRIPTION.Text.Trim() + "',DEFAULTCURR='" + this.hd_comboDEFAULTCURR.Value.Trim() + "',ISSEA='" + cbISSEA.Checked + "',ISAIR='" + cbISAIR.Checked + "',ISTRUCKING='" + cbISTRUCKING.Checked + "',ISTRUCKINGFIXED='" + cbISTRUCKINGFIXED.Checked + "',DEFAULTUNIT='" + ddlDEFAULTUNIT.Text.Trim() + "',DEFAULTDEBIT='" + ddlDEFAULTDEBIT.Text.Trim() + "',DEFAULTCREDIT='" + ddlDEFAULTCREDIT.Text.Trim() + "',MODIFIEDUSER='" + strUserID.Trim() + "',MODIFIEDTIME=getdate(),FEETYPE='" + ddlFEETYPE.Text.Trim() + "',ISWMS='" + cbISWMS.Checked + "',FEEGROUP='" + this.hd_comboFEEGROUP.Value.Trim() + "' where GID='" + ViewState["GID"].ToString().Trim() + "'";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
if (bl)
{
ViewState["strHandleType"] = "edit";
this.hdHandleType.Value = "edit";
FeeCodeDA feeCodeDA = new FeeCodeDA();
DataTable sourceTable = new DataTable();
string strSql = " SELECT GID,ISNULL(FEECODE,'')+' '+ISNULL(Name,'') AS FullName,Name FROM code_fee ORDER BY FEECODE ASC ";
sourceTable = feeCodeDA.GetExcuteSql(strSql).Tables[0];
if (Cache["feecodes"] != null)
{
Cache["feecodes"] = sourceTable;
}
else
{
Cache.Insert("feecodes", sourceTable);
}
return true;
}
else
{
return false;
}
}
protected void getEnter()
{
if (tbFEECODE.Text.Trim() == "" || this.hdNAME.Value.Trim() == "")
{
Response.Write("<script>alert('费用代码或名称不允许为空!');</script>");
return;
}
//
string strls = "";
bool bl = false;
strHandleType = ViewState["strHandleType"].ToString();//this.hdHandleType.Value.Trim();
if (strHandleType.Equals("add"))//新增
{
//
strls = T_ALL_DA.GetStrSQL("FEECODE", "select FEECODE from code_fee where FEECODE='" + tbFEECODE.Text.Trim() + "'");
if (strls.Trim() != "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('费用代码不允许重复!');</script>");
return;
}
//
strls = T_ALL_DA.GetStrSQL("NAME", "select [NAME] from code_fee where [NAME]='" + this.hdNAME.Value.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("FEECODE", "select FEECODE from code_fee where FEECODE='" + tbFEECODE.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("NAME", "select [NAME] from code_fee where [NAME]='" + this.hdNAME.Value.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("NAME", "select [NAME] from code_fee where GID='" + ViewState["GID"].ToString().Trim() + "'");
if (strls.Trim() != this.hdNAME.Value.Trim())
{
strls = T_ALL_DA.GetStrSQL("FEENAME", "select FEENAME from ch_fee where FEENAME='" + 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>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key7", "<script>alert('操作成功!');window.opener.location.reload();history.back();</script>");
//Response.Write("<script>alert('操作成功!');window.opener.location.reload();history.back();</script>");
return;
}
else
{
Response.Write("<script>alert('出错,请重新填写!');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key8", "<script>alert('出错,请重新填写!');</script>");
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)
{
string strls = T_ALL_DA.GetStrSQL("NAME", "SELECT A.* FROM code_fee as A INNER JOIN ch_fee as B ON A.NAME = B.FEENAME WHERE A.GID='" + ViewState["GID"].ToString().Trim() + "'");
if (strls.Trim() != "")
{
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key9", "<script>alert('费用名称已经启用,因此不允许删除!');</script>");
Response.Write("<script>alert('费用名称已经启用,因此不允许删除!');history.back();</script>");
return;
}
//
bool bl = T_ALL_DA.GetExecuteSqlCommand("delete from code_fee where GID='" + ViewState["GID"].ToString().Trim() + "'");
if (bl)
{ //
ViewState["strHandleType"] = "edit";
this.hdHandleType.Value = "edit";
getDataSet("select top 1 * from code_fee order by FEECODE");
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
//
Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", "<script>reloadParent('" + ViewState["GID"].ToString().Trim() + "','del');</script>");
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key11", "<script>alert('删除成功!');window.opener.location.reload();history.back();</script>");
//Response.Write("<script>alert('删除成功!');window.opener.location.reload();history.back();</script>");
return;
}
else
{
//
ibDel.Enabled = true;
ibAdd.Enabled = true;
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key12", "<script>alert('删除出错!');</script>");
Response.Write("<script>alert('删除出错!');</script>");
return;
}
}
protected void getFEETYPE()
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
ddlFEETYPE.Items.Clear();
DataSet ds = T_ALL_DA.GetAllSQL("select KEYVALUE from crm_key_code where KEYTYPE='费用类型' and KEYVALUE<>'' and KEYVALUE is not null");
if (ds != null)
{
ddlFEETYPE.DataSource = ds.Tables[0];
ddlFEETYPE.DataTextField = "KEYVALUE";
ddlFEETYPE.DataValueField = "KEYVALUE";
ddlFEETYPE.DataBind();
}
ddlFEETYPE.Items.Add("");
}
}
}