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.

540 lines
21 KiB
C#

11 months ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Data;
using System.Text;
using System.Collections;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using DSWeb.DataAccess;
using System.Data.SqlClient;
using System.Web.Script.Serialization;
namespace DSWeb.ParameterSet
{
public partial class CodeOwefeeModuleSet : System.Web.UI.Page
{
public string strdate;//用户GID
public string strUserID ;//登录用户GID
public string strCompanyID ;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
public string strBsno ;
public string strIsAble;//业务状态是否已经已经锁定如果锁定页面是只读
CodeOwefeeModuleSetDA CodeOwefeeModuleSetDA = new CodeOwefeeModuleSetDA();
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();
}
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)
{
this.LoadGridView();
//
//DataSet ds = T_ALL_DA.GetTableField("op_seae");
string sSQL = "select ColumnsName from [VW_SysObjects] where ObjectsName='VW_OP_SEA_ALL' order by [ColumnsName]";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
ListBox1.Items.Add(new ListItem(myRow["ColumnsName"].ToString().Trim(), myRow["ColumnsName"].ToString().Trim()));
}
}
//
sSQL = "select GID,FEECODE,[NAME] from code_fee order by [NAME]";
ds = T_ALL_DA.GetAllSQL(sSQL);
foreach (DataTable myTable in ds.Tables)
{
foreach (DataRow myRow in myTable.Rows)//遍历表
{
ListBox3.Items.Add(new ListItem(myRow["NAME"].ToString().Trim(), myRow["NAME"].ToString().Trim()));
}
}
}
}
/// <summary>
/// 公共消息提示
/// </summary>
/// <param name="strtext"></param>
public void CommonMessageBox(string strtext)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('"+strtext+"')</script>");
}
/// <summary>
/// 自动生成的newid主键
/// </summary>
/// <returns></returns>
protected String getBSNO(String strLS)
{
string strBSNO = Guid.NewGuid().ToString();
strBSNO = strBSNO.Replace("-", "");
strBSNO = strLS + strBSNO;
return strBSNO;
}
/// <summary>
/// 提取规则编号
/// </summary>
/// <param name="strRULENAME">规则项目名称</param>
/// <param name="strfield">需要加规则的字段</param>
/// <returns></returns>
protected String getCodeRule()
{
//调用编码规则
string strRULENOLENGTH = "";
int iRULENOLENGTH = 0;
int inum = 0;
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
strRULENOLENGTH = T_ALL_DA.GetStrSQL("TABLENAME", "select top 1 TABLENAME from [code_owefee_module] where TABLENAME like 'temp_owefee_module_%' order by TABLENAME DESC");
if (strRULENOLENGTH == "")
{
strRULENOLENGTH = "1";
}
else
{
inum = int.Parse(strRULENOLENGTH.Trim());
inum = inum + 1;
strRULENOLENGTH = inum.ToString();
}
int j = iRULENOLENGTH - strRULENOLENGTH.Length;
for (int i = 1; i <= j; i++)
{
strRULENOLENGTH = "0" + strRULENOLENGTH;
}
//
strRULENOLENGTH = "temp_owefee_module_" + strRULENOLENGTH;
return strRULENOLENGTH;
}
protected void btCreate_Click(object sender, EventArgs e)
{
if (this.gv_gid.Value == "")
{
this.CommonMessageBox("请先选择模块名!");
return;
}
int result = CodeOwefeeModuleSetDA.CreateTable(this.gv_gid.Value);
if (result == 1)
{
this.CommonMessageBox("生成成功!");
return;
}
else
{
this.CommonMessageBox("已经生成过,不允许重复生成!");
return;
}
}
/////////////////////////////////////********************gridview应用*******************************************/////////////////
/// <summary>
/// 加载gridview信息
/// </summary>
/// <param name="bsno"></param>
public void LoadGridView()
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
DataSet ds = T_ALL_DA.GetAllSQL("select GID,MODULENAME from code_owefee_module order by MODULENAME");
if (ds != null)
{
this.gvModule.DataSource = ds.Tables[0];
this.gvModule.DataKeyNames = new string[] { "GID" };
this.gvModule.DataBind();
}
else
{
this.gvModule.DataSource = null;
this.gvModule.DataBind();
}
}
/// <summary>
/// 添加(创建新的)集装箱信息 **
/// </summary>
protected void imgadd_Click(object sender, ImageClickEventArgs e)
{
this.gv_gid.Value = getBSNO("CodeOweFeeModule");
CodeOwefeeModuleSetDA.Insert(this.gv_gid.Value, "", getCodeRule(), strUserID, strCompanyID);
this.LoadGridView();
}
protected void gvModule_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "deleteCon")
{
string strGID = e.CommandArgument.ToString();
int ii = CodeOwefeeModuleSetDA.DelteGid(strGID);
if (ii == 1)
{
//this.CommonMessageBox("删除成功");
LoadGridView();
}
else
{
this.CommonMessageBox("删除失败");
}
}
if (e.CommandName == "saveCon")
{
CodeOweFeeModuleEntity CodeOweFeeModuleEntity = new CodeOweFeeModuleEntity();
CodeOweFeeModuleEntity.GID = e.CommandArgument.ToString();
GridViewRow row = ((Control)e.CommandSource).BindingContainer as GridViewRow;
TextBox remark = (TextBox)row.FindControl("txt_MODULENAME");
CodeOweFeeModuleEntity.MODULENAME = remark.Text.Trim();
int intresult = CodeOwefeeModuleSetDA.UpdateGid(CodeOweFeeModuleEntity);
if (intresult == 1)
{
//this.CommonMessageBox("操作成功");
LoadGridView();
}
else
{
this.CommonMessageBox("操作失败");
}
gvModule.EditIndex = -1;
}
}
protected void gvModule_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
RadioButton rb = (RadioButton)e.Row.FindControl("rbtSelect");
if (rb != null)
{
rb.Attributes.Add("onclick", "onClientClick0('" + rb.ClientID + "','" + e.Row.RowIndex + "');getgvFee('" + gvModule.DataKeys[e.Row.RowIndex].Value.ToString() + "');");//把选中行的RowIndex也传过去提交后在服务器端取值时用
}
//e.Row.Cells[1].Attributes.Add("onclick", "return getgvFee('" + gvModule.DataKeys[e.Row.RowIndex].Value.ToString() + "')");
//单击行选中变色
e.Row.Attributes.Add("onclick ", "if(window.oldtr!=null){window.oldtr.runtimeStyle.cssText='';}this.runtimeStyle.cssText='background-color:#A7CDF0';window.oldtr=this;");//字体变色this.style.color='#FFFFFF';
}
}
protected void btgvfee_Click(object sender, EventArgs e)
{
LoadGridListBox2();
LoadGridViewFee();
}
/////////////////////////////////////********************gridview fee应用*******************************************/////////////////
/// <summary>
/// 加载gridview信息
/// </summary>
/// <param name="bsno"></param>
public void LoadGridViewFee()
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string sSQL = "select GID,FIELDS,FIELDNAME from code_owefee_module_detail where LINKGID='" + this.gv_gid.Value + "' and ISFEEFIELD=1 order by FIELDNAME";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
if (ds != null)
{
this.gvFee.DataSource = ds.Tables[0];
this.gvFee.DataKeyNames = new string[] { "GID" };
this.gvFee.DataBind();
}
else
{
this.gvFee.DataSource = null;
this.gvFee.DataBind();
}
}
/// <summary>
/// 添加(创建新的)集装箱信息 **
/// </summary>
protected void imgaddfee_Click(object sender, ImageClickEventArgs e)
{
if(this.gv_gid.Value=="")
{
this.CommonMessageBox("请先选择模块名!");
return;
}
this.gv_gidfee.Value = getBSNO("CodeOweFeeModuleDetail");
CodeOwefeeModuleSetDA.InsertFee(this.gv_gidfee.Value, this.gv_gid.Value, "", "", true, 1);
this.LoadGridViewFee();
}
protected void gvFee_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "deleteCon")
{
string strGID = e.CommandArgument.ToString();
int ii = CodeOwefeeModuleSetDA.DelteGidFee(strGID);
if (ii == 1)
{
//this.CommonMessageBox("删除成功");
LoadGridViewFee();
}
else
{
this.CommonMessageBox("删除失败");
}
}
if (e.CommandName == "saveCon")
{
CodeOweFeeModuleDetailEntity CodeOweFeeModuleDetailEntity = new CodeOweFeeModuleDetailEntity();
CodeOweFeeModuleDetailEntity.GID = e.CommandArgument.ToString();
GridViewRow row = ((Control)e.CommandSource).BindingContainer as GridViewRow;
TextBox remark = (TextBox)row.FindControl("txt_FIELDNAME");
CodeOweFeeModuleDetailEntity.FIELDS = remark.Text.Trim();
CodeOweFeeModuleDetailEntity.FIELDNAME = remark.Text.Trim();
CodeOweFeeModuleDetailEntity.LINKGID = this.gv_gid.Value.Trim();
int intresult = CodeOwefeeModuleSetDA.UpdateGidFee(CodeOweFeeModuleDetailEntity);
if (intresult == 1)
{
//this.CommonMessageBox("操作成功");
LoadGridViewFee();
}
else
{
this.CommonMessageBox("操作失败");
}
gvFee.EditIndex = -1;
}
}
protected void gvFee_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
RadioButton rb = (RadioButton)e.Row.FindControl("rbtSelect");
if (rb != null)
{
rb.Attributes.Add("onclick", "onClientClick1('" + rb.ClientID + "','" + e.Row.RowIndex + "');getgvDetailFee('" + gvFee.DataKeys[e.Row.RowIndex].Value.ToString() + "');");//把选中行的RowIndex也传过去提交后在服务器端取值时用
}
//e.Row.Cells[1].Attributes.Add("onclick", "return getgvDetailFee('" + gvFee.DataKeys[e.Row.RowIndex].Value.ToString() + "')");
//单击行选中变色
e.Row.Attributes.Add("onclick ", "if(window.oldtr!=null){window.oldtr.runtimeStyle.cssText='';}this.runtimeStyle.cssText='background-color:#A7CDF0';window.oldtr=this;");//字体变色this.style.color='#FFFFFF';
}
}
protected void btgvDetailFee_Click(object sender, EventArgs e)
{
LoadGridListBox4();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary>
/// 加载ListBox2信息
/// </summary>
/// <param name="bsno"></param>
public void LoadGridListBox2()
{
ListBox2.Items.Clear();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string sSQL = "select GID,FIELDNAME from code_owefee_module_detail where LINKGID='" + this.gv_gid.Value + "' and ISFEEFIELD=0 order by FIELDNAME";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
if (ds != null)
{
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
for (int i= 0; i < ListBox1.Items.Count; i++)
{
if (ListBox1.Items[i].Value.Trim() == ds.Tables[0].Rows[j]["FIELDNAME"].ToString().Trim())
{
ListBox2.Items.Add(new ListItem(ListBox1.Items[i].Text, ListBox1.Items[i].Value));
}
}
}
}
}
protected void Button5_Click(object sender, EventArgs e)
{
if (this.gv_gid.Value == "")
{
this.CommonMessageBox("请先选择模块名!");
return;
}
for (int i = 0; i < ListBox2.Items.Count; i++)
{
this.gv_gidfee.Value = getBSNO("CodeOweFeeModuleDetail");
CodeOwefeeModuleSetDA.InsertFee(this.gv_gidfee.Value, this.gv_gid.Value, ListBox2.Items[i].Value, ListBox2.Items[i].Text, false, i);
}
}
protected void Button4_Click(object sender, EventArgs e)
{
if (this.gv_gid.Value == "")
{
this.CommonMessageBox("请先选择模块名!");
return;
}
if (ListBox2.SelectedIndex < 0)
return;
//ListBox1.Items.Add(new ListItem(ListBox2.SelectedItem.Text, ListBox2.SelectedItem.Value));
ListBox2.Items.Remove(new ListItem(ListBox2.SelectedItem.Text, ListBox2.SelectedItem.Value));
}
protected void Button3_Click(object sender, EventArgs e)
{
if (this.gv_gid.Value == "")
{
this.CommonMessageBox("请先选择模块名!");
return;
}
//for (int i = 0; i < ListBox2.Items.Count; i++)
//{
// ListBox1.Items.Add(new ListItem(ListBox2.Items[i].Text, ListBox2.Items[i].Value));
//}
ListBox2.Items.Clear();
}
protected void Button2_Click(object sender, EventArgs e)
{
if (this.gv_gid.Value == "")
{
this.CommonMessageBox("请先选择模块名!");
return;
}
if (ListBox1.SelectedIndex < 0)
return;
ListBox2.Items.Add(new ListItem(ListBox1.SelectedItem.Text, ListBox1.SelectedItem.Value));
//ListBox1.Items.Remove(new ListItem(ListBox1.SelectedItem.Text, ListBox1.SelectedItem.Value));
}
protected void Button1_Click(object sender, EventArgs e)
{
if (this.gv_gid.Value == "")
{
this.CommonMessageBox("请先选择模块名!");
return;
}
for (int i = 0; i < ListBox1.Items.Count; i++)
{
ListBox2.Items.Add(new ListItem(ListBox1.Items[i].Text, ListBox1.Items[i].Value));
}
//ListBox1.Items.Clear();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary>
/// 加载ListBox4信息
/// </summary>
/// <param name="bsno"></param>
public void LoadGridListBox4()
{
ListBox4.Items.Clear();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string sSQL = "select GID,FIELDNAME from code_owefee_module_detail_fee where LINKGID='" + this.gv_gidfee.Value + "' order by FIELDNAME";
DataSet ds = T_ALL_DA.GetAllSQL(sSQL);
if (ds != null)
{
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
for (int i = 0; i < ListBox3.Items.Count; i++)
{
if (ListBox3.Items[i].Value.Trim() == ds.Tables[0].Rows[j]["FIELDNAME"].ToString().Trim())
{
ListBox4.Items.Add(new ListItem(ListBox3.Items[i].Text, ListBox3.Items[i].Value));
}
}
}
}
}
protected void Button10_Click(object sender, EventArgs e)
{
if (this.gv_gidfee.Value == "")
{
this.CommonMessageBox("请先选择费用分组名!");
return;
}
for (int i = 0; i < ListBox4.Items.Count; i++)
{
CodeOwefeeModuleSetDA.InsertDetailFee(this.gv_gidfee.Value, ListBox4.Items[i].Value, i);
}
}
protected void Button9_Click(object sender, EventArgs e)
{
if (this.gv_gidfee.Value == "")
{
this.CommonMessageBox("请先选择费用分组名!");
return;
}
if (ListBox4.SelectedIndex < 0)
return;
//ListBox3.Items.Add(new ListItem(ListBox4.SelectedItem.Text, ListBox4.SelectedItem.Value));
ListBox4.Items.Remove(new ListItem(ListBox4.SelectedItem.Text, ListBox4.SelectedItem.Value));
}
protected void Button8_Click(object sender, EventArgs e)
{
if (this.gv_gidfee.Value == "")
{
this.CommonMessageBox("请先选择费用分组名!");
return;
}
//for (int i = 0; i < ListBox4.Items.Count; i++)
//{
// ListBox3.Items.Add(new ListItem(ListBox4.Items[i].Text, ListBox4.Items[i].Value));
//}
ListBox4.Items.Clear();
}
protected void Button7_Click(object sender, EventArgs e)
{
if (this.gv_gidfee.Value == "")
{
this.CommonMessageBox("请先选择费用分组名!");
return;
}
if (ListBox3.SelectedIndex < 0)
return;
ListBox4.Items.Add(new ListItem(ListBox3.SelectedItem.Text, ListBox3.SelectedItem.Value));
//ListBox3.Items.Remove(new ListItem(ListBox3.SelectedItem.Text, ListBox3.SelectedItem.Value));
}
protected void Button6_Click(object sender, EventArgs e)
{
if (this.gv_gidfee.Value == "")
{
this.CommonMessageBox("请先选择费用分组名!");
return;
}
for (int i = 0; i < ListBox3.Items.Count; i++)
{
ListBox4.Items.Add(new ListItem(ListBox3.Items[i].Text, ListBox3.Items[i].Value));
}
//ListBox3.Items.Clear();
}
//
}
}