DS7/DSWeb/ParameterSet/CodeRuleSet.aspx.cs

208 lines
8.5 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;
namespace DSWeb.ParameterSet
{
public partial class CodeRuleSet : System.Web.UI.Page
{
public string sSQL = String.Empty;
TopSeaeBillmanageEntity TopSeaeBillmanageEntity = new TopSeaeBillmanageEntity();
TopSeaeBillmanageDA TopSeaeBillmanageDA = new TopSeaeBillmanageDA();
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;
//strUserID = "";
}
//
if (!IsPostBack)
{
ddlRULETYPE.Items.Clear();
DataSet ds = T_ALL_DA.GetAllSQL("select RULETYPE,RULENAME from code_rule_no group by RULETYPE,RULENAME order by RULETYPE");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ddlRULETYPE.Items.Add(new ListItem(ds.Tables[0].Rows[i]["RULENAME"].ToString().Trim(), ds.Tables[0].Rows[i]["RULETYPE"].ToString().Trim()));
}
//ddlRULETYPE.SelectedValue = "1";
//
getRULENAME();
getRULEDATE();
//
getSHOW();
}
}
protected void getRULENAME()
{
ddlRULENAME.Items.Clear();
DataSet ds = T_ALL_DA.GetAllSQL("select RULEBLNO from code_rule_no where RULENAME='" + ddlRULETYPE.SelectedItem.Text.Trim() + "' group by RULEBLNO order by RULEBLNO");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
ddlRULENAME.Items.Add(ds.Tables[0].Rows[i]["RULEBLNO"].ToString().Trim());
}
}
protected void getRULEDATE()
{
ddlRULEDATE.Items.Clear();
DataSet ds = T_ALL_DA.GetAllSQL("select RULEDATETYPE from code_rule_no where RULENAME='" + ddlRULETYPE.SelectedItem.Text.Trim() + "' and RULEBLNO='" + ddlRULENAME.SelectedValue.Trim() + "' group by RULEDATETYPE order by RULEDATETYPE");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string ask = ds.Tables[0].Rows[i]["RULEDATETYPE"].ToString().Trim();
ddlRULEDATE.Items.Add(ds.Tables[0].Rows[i]["RULEDATETYPE"].ToString().Trim());
}
}
protected void getSHOW()
{
this.hdGID.Value = "";
ddlRULEYEAR.Text = "4";
tbRULENOLENGTH.Text = "4";
tbRULENOSTART.Text = "0001";
//
//int iRULETYPE = int.Parse(ddlRULETYPE.SelectedValue.Trim());
//if (iRULETYPE == 1)//规则类型 1海运出口 2海运进口 3空运出口 4空运进口 5监管车
//{
// tbRULECONTENT.Text = "SE";
//}
//else if (iRULETYPE == 2)
//{
// tbRULECONTENT.Text = "SI";
//}
//else if (iRULETYPE == 3)
//{
// tbRULECONTENT.Text = "TSE";
//}
//else if (iRULETYPE == 4)
//{
// tbRULECONTENT.Text = "AI";
//}
//else if (iRULETYPE == 5)
//{
// tbRULECONTENT.Text = "TT";
//}
//else
//{
// tbRULECONTENT.Text = "";
//}
tbRULECONTENT.Text = T_ALL_DA.GetStrSQL("RULECODE", "select RULECODE from code_rule_no where RULENAME='" + ddlRULETYPE.SelectedItem.Text.Trim() + "' and RULEBLNO='" + ddlRULENAME.SelectedValue.Trim() + "' group by RULECODE order by RULECODE");
//
cbISSTARTUSING.Checked = false;
cbISALLOWEDITS.Checked = false;
cbISCLEAREDINEARLY.Checked = false;
cbISCOMPANY.Checked = false;
cbISDEPT.Checked = false;
//
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + ddlRULENAME.SelectedValue.Trim() + "' and RULETYPE=" + ddlRULETYPE.SelectedValue.ToString().Trim());
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
this.hdGID.Value=ds.Tables[0].Rows[0]["GID"].ToString().Trim();
ddlRULENAME.SelectedValue = ds.Tables[0].Rows[0]["RULENAME"].ToString().Trim();
tbRULECONTENT.Text = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
ddlRULEDATE.SelectedValue=ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim();
ddlRULEYEAR.Text=ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim();
tbRULENOLENGTH.Text = ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim();
tbRULENOSTART.Text = ds.Tables[0].Rows[0]["RULENOSTART"].ToString().Trim();
//
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
{
cbISSTARTUSING.Checked=true;
}
if (ds.Tables[0].Rows[0]["ISALLOWEDITS"].ToString().Trim().Equals("True"))
{
cbISALLOWEDITS.Checked = true;
}
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
cbISCLEAREDINEARLY.Checked = true;
}
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
{
cbISCOMPANY.Checked = true;
}
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
{
cbISDEPT.Checked = true;
}
}
}
//
if (ddlRULETYPE.SelectedItem.Text.Trim() == "凭证号")
{
Label2.Visible = true;
tbRULENOSTART.Visible = true;
}
else
{
Label2.Visible = false;
tbRULENOSTART.Visible = false;
}
}
protected void btnEnter_Click(object sender, ImageClickEventArgs e)
{
string alt = "";
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + ddlRULENAME.SelectedValue.Trim() + "' and RULETYPE=" + ddlRULETYPE.SelectedValue.ToString().Trim());
if (ds == null)
{
alt = T_ALL_DA.GetCodeRuleInsert(ddlRULENAME.SelectedValue.Trim(), tbRULECONTENT.Text, ddlRULEDATE.SelectedValue.Trim(), ddlRULEYEAR.Text, tbRULENOLENGTH.Text, cbISSTARTUSING.Checked, cbISALLOWEDITS.Checked, cbISCLEAREDINEARLY.Checked, cbISCOMPANY.Checked, cbISDEPT.Checked, strUserID.Trim(), int.Parse(ddlRULETYPE.SelectedValue.ToString().Trim()), tbRULENOSTART.Text);
}
else
{
alt = T_ALL_DA.GetCodeRuleUpdate(this.hdGID.Value, ddlRULENAME.SelectedValue.Trim(), tbRULECONTENT.Text, ddlRULEDATE.SelectedValue.Trim(), ddlRULEYEAR.Text, tbRULENOLENGTH.Text, cbISSTARTUSING.Checked, cbISALLOWEDITS.Checked, cbISCLEAREDINEARLY.Checked, cbISCOMPANY.Checked, cbISDEPT.Checked, strUserID.Trim(), int.Parse(ddlRULETYPE.SelectedValue.ToString().Trim()), tbRULENOSTART.Text);
}
if (alt != "")
{
Response.Write("<script>alert('"+alt+"');history.back();</script>");
return;
}
else
{
Response.Write("<script>alert('成功提交!');</script>");
return;
}
}
protected void ddlRULENAME_SelectedIndexChanged(object sender, EventArgs e)
{
getRULEDATE();
getSHOW();
}
protected void ddlRULETYPE_SelectedIndexChanged(object sender, EventArgs e)
{
getRULENAME();
getRULEDATE();
getSHOW();
}
}
}