📄 corporation_reg.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace BDStudioBase.syssoft
{
/// <summary>
/// corporation_reg 的摘要说明。
/// </summary>
public class corporation_reg : FormBase
{
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.RadioButton rdoAll;
protected System.Web.UI.WebControls.RadioButton rdoTable;
protected System.Web.UI.WebControls.LinkButton linkbSearch;
protected System.Web.UI.WebControls.Button cbAdd;
protected System.Web.UI.WebControls.Button cbEdit;
protected System.Web.UI.WebControls.Button cbDelete;
protected System.Web.UI.WebControls.Button cbReturn;
protected System.Web.UI.WebControls.Label Lab_title;
protected System.Web.UI.WebControls.DataGrid dbGridMain1;
protected System.Web.UI.WebControls.Label labMessage1;
protected System.Web.UI.WebControls.LinkButton linkbPrev1;
protected System.Web.UI.WebControls.Label labPage1;
protected System.Web.UI.WebControls.LinkButton linkbNext1;
protected System.Web.UI.WebControls.LinkButton linkbJump1;
protected System.Web.UI.WebControls.TextBox txtPageNum1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.TextBox txtCName;
protected System.Web.UI.WebControls.TextBox txtEName;
/*定义窗体变量,根据设计报告改变*/
private string s_pk="c_num";//关键字变量
private int ColumnCount=4;//主表格固定列数量
string m_num="258";
protected COM_SystemClient COM_SystemClient=new COM_SystemClient();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
this.o_str_FormName="corporation_reg";
this.o_str_FormUrl="corporation_reg.aspx";
this.o_str_InputFile1="corporation_reg_input.aspx";
this.o_str_ModifyFile1="corporation_reg_edit.aspx";
this.o_str_DisplayFile1 = "corporation_reg_display.aspx";
this.o_str_FormStatusData=this.GetValueFromUserLog(this.o_str_FormName);
if(!Page.IsPostBack)
{
Session["PageNum1"]=0;
Session["SelectIndex1"]=-1;
Session["SelectIndexL1"]=-1;
Session["dv1"]=null;
if (this.o_str_FormStatusData!="W")
{
string[] arr_window_value=this.o_str_FormStatusData.Split(new char[]{','});
Session["PageNum1"]=Int32.Parse(arr_window_value[0]);
Session["SelectIndex1"]=Int32.Parse(arr_window_value[1]);
Session["SelectIndexL1"]=Int32.Parse(arr_window_value[1]);
//Response.Write(arr_window_value[1]);
UserLogClose(this.o_str_FormName);//关闭记录
}
string[] str_FieldValue = {m_num,"dbGridMain1",string.Empty,string.Empty};
this.o_ds_FormData=this.COM_SystemClient.DsMainListForAll(str_FieldValue);//生成填入dbGridMain1的数据集
this.DataRead(this.o_ds_FormData,"dv1");
if(this.o_ds_FormData.Tables[0].Rows.Count>0)
{
this.dbGridMain1.SelectedIndex=0;
}
if((int)Session["SelectIndex1"]!=-1)
{
this.dbGridMain1.SelectedIndex=(int)Session["SelectIndex1"];
}
}
SaveStatus();//存储当前页面各种状态
FormInit(); //填充dbGridMain1数据
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.linkbSearch.Click += new System.EventHandler(this.linkbSearch_Click);
this.cbAdd.Click += new System.EventHandler(this.cbAdd_Click);
this.cbEdit.Click += new System.EventHandler(this.cbEdit_Click);
this.cbDelete.Click += new System.EventHandler(this.cbDelete_Click);
this.cbReturn.Click += new System.EventHandler(this.cbReturn_Click);
this.dbGridMain1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dbGridMain1_ItemCommand);
this.dbGridMain1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dbGridMain1_ItemDataBound);
this.linkbJump1.Click += new System.EventHandler(this.linkbJump1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void FormInit()
{
DataView dvdata;
if(Session["dv1"]!=null)
{
/*表格页数初始化*/
this.o_int_PageNum=(int)Session["PageNum1"];
dvdata=(DataView)Session["dv1"];
/*参数说明:主表格控件名称、表头数据集、空间固定列数量、主键名称、数据集*/
this.DbGridInit(this.dbGridMain1,this.COMInterface.DsInterfaceTitle(m_num,"dbGridMain1"),ColumnCount,s_pk,ref dvdata);
this.PageShow();
}
}
private void SaveStatus()
{
this.o_str_FormStatusData=this.dbGridMain1.CurrentPageIndex.ToString()+","+this.dbGridMain1.SelectedIndex.ToString();
this.SaveFormStatus(this.o_str_FormName,this.o_str_FormStatusData);
}
private void PageShow()
{
if(dbGridMain1.PageCount>1)
{
this.linkbNext1.Visible=true;
this.linkbPrev1.Visible=true;
this.labPage1.Visible=true;
// this.labPage2.Visible = true;
this.txtPageNum1.Visible = true;
this.linkbJump1.Visible = true;
this.PageLabelShow(ref this.labPage1,this.dbGridMain1.CurrentPageIndex+1,this.dbGridMain1.PageCount);
}
else
{
this.linkbNext1.Visible=false;
this.linkbPrev1.Visible=false;
this.labPage1.Visible=false;
// this.labPage2.Visible = false;
this.txtPageNum1.Visible = false;
this.linkbJump1.Visible = false;
}
}
/*翻页按钮事件*/
protected void PagerButtonClick(object sender, System.EventArgs e)
{
int PageNum=this.dbGridMain1.CurrentPageIndex;
string arg=((LinkButton)sender).CommandArgument;
switch(arg)
{
case("prev"):
if(PageNum>0)
PageNum--;
break;
case("next"):
if(PageNum<(this.dbGridMain1.PageCount-1))
PageNum++;
break;
}
//记录当前页
Session["PageNum1"]=PageNum;
this.dbGridMain1.CurrentPageIndex = PageNum;
this.dbGridMain1.DataBind();
this.PageShow();
this.FormInit();
}
private void linkbJump1_Click(object sender, System.EventArgs e)
{
if (this.txtPageNum1.Text != string.Empty && this.txtPageNum1.Text != null)
{
int pagenum = (Int32.Parse(this.txtPageNum1.Text)-1);
if ( pagenum > (this.dbGridMain1.PageCount-1))
{
this.dbGridMain1.CurrentPageIndex = (this.dbGridMain1.PageCount-1);
}
else
{
this.dbGridMain1.CurrentPageIndex = pagenum;
}
Session["PageNum1"]=this.dbGridMain1.CurrentPageIndex;
this.dbGridMain1.DataBind();
this.PageShow();
this.FormInit();
}
}
private void linkbSearch_Click(object sender, System.EventArgs e)
{
/*检索按钮事件*/
if (this.txtCName.Text != null && this.txtCName.Text.Trim() != string.Empty)
{
string[] str_accountnum = {string.Empty,this.txtCName.Text};
DataSet ds = this.COM_SystemClient .DsMainListForAll(str_accountnum);
if(this.rdoAll.Checked)
{
this.DataRead(ds,"dv1");
}
if(this.rdoTable.Checked)
{
//如果是表格内检索则先清空数据集,然后再填充
DataView dv;
dv=(DataView)Session["dv1"];
/*选择条件行*/
//DataRow[] currRows=dv.Table.Select(eld,s_terms,s_value,"2"),null,DataViewRowState.CurrentRows);
string strsql = string.Format(" c_cname like '%{0}%' ",str_accountnum[1]);
DataRow[] currRows=dv.Table.Select( strsql,null,DataViewRowState.CurrentRows);
if(currRows.Length>0)
{
foreach (DataRow myRow in currRows)
{
dv.Table.Rows.Remove(myRow);
}
}
Session["dv1"]=dv;
this.DataRead(ds,"dv1");
}
}
else
{
if (this.txtEName.Text != null && this.txtEName.Text.Trim() != string.Empty)
{
string[] str_accountname = {this.txtEName.Text,string.Empty};
DataSet ds = this.COM_SystemClient.DsMainListForAll(str_accountname);
if(this.rdoAll.Checked)
{
this.DataRead(ds,"dv1");
}
if(this.rdoTable.Checked)
{
//如果是表格内检索则先清空数据集,然后再填充
DataView dv;
dv=(DataView)Session["dv1"];
/*选择条件行*/
//DataRow[] currRows=dv.Table.Select(eld,s_terms,s_value,"2"),null,DataViewRowState.CurrentRows);
string strsql = string.Format(" c_name like '%{0}%' ",str_accountname[0]);
DataRow[] currRows=dv.Table.Select( strsql,null,DataViewRowState.CurrentRows);
if(currRows.Length>0)
{
foreach (DataRow myRow in currRows)
{
dv.Table.Rows.Remove(myRow);
}
}
Session["dv1"]=dv;
this.DataRead(ds,"dv1");
}
}
}
/*读取数据*/
this.FormInit();
}
private void cbAdd_Click(object sender, System.EventArgs e)
{
/*增加按钮事件*/
this.CreatUserLogParentWindow("corporation_reg_input",this.o_str_FormUrl);//建立子窗口的父窗口数据值
Response.Redirect(this.o_str_InputFile1);
}
private void cbEdit_Click(object sender, System.EventArgs e)
{
if(this.dbGridMain1.Columns[item_cou+1].Visible==false)
{
this.dbGridMain1.Columns[item_cou+1].Visible=true;
}
if(this.dbGridMain1.Columns[item_cou+2].Visible==true)
{
this.dbGridMain1.Columns[item_cou+2].Visible=false;
}
}
private void cbDelete_Click(object sender, System.EventArgs e)
{
if(this.dbGridMain1.Columns[item_cou+2].Visible==false)
{
this.dbGridMain1.Columns[item_cou+2].Visible=true;
}
if(this.dbGridMain1.Columns[item_cou+1].Visible==true)
{
this.dbGridMain1.Columns[item_cou+1].Visible=false;
}
}
private void cbReturn_Click(object sender, System.EventArgs e)
{
Response.Redirect(this.o_str_FormUrl);
}
private void dbGridMain1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
//添加编辑脚本
if(e.CommandName == "edit")
{
string sSendId="";
DataView dvdata=(DataView)Session["dv1"];
foreach(DataRow row in dvdata.Table.Rows)
{
this.COMGfunction.StringAdd(ref sSendId,"",row["c_num"].ToString(),",");
}
this.Param_Open("corporation_reg_edit");
this.Param_set("as_pk",e.Item.Cells[1].Text);
this.Param_set("as_sendid",sSendId);
SaveStatus();
this.CreatUserLogParentWindow("corporation_reg_edit",this.o_str_FormUrl);//建立子窗口的父窗口数据值
Response.Redirect(this.o_str_ModifyFile1);
}
//添加删除脚本
if(e.CommandName == "delete")
{
string strSql = string.Format("{0} = '{1}'",this.s_pk,e.Item.Cells[1].Text);
string sReturn = string.Empty;
this.COM_SystemClient.DeleteData(strSql,ref sReturn);
string[] str_FieldValue = {m_num,"dbGridMain1" };
this.o_ds_FormData=this.COM_SystemClient.DsMainListForAll(str_FieldValue);
this.DataRead(this.o_ds_FormData,"dv1");
if(this.o_ds_FormData.Tables[0].Rows.Count>0)
{
this.dbGridMain1.SelectedIndex=0;
}
if((int)Session["SelectIndex1"]!=-1)
{
this.dbGridMain1.SelectedIndex=(int)Session["SelectIndex1"];
//Session["SelectIndex1"]=-1;
}
SaveStatus();
FormInit();
this.dbGridMain1.CurrentPageIndex = (int)Session["PageNum1"];
this.dbGridMain1.DataBind();
this.PageShow();
this.labMessage1.Text = sReturn;
this.labMessage1.Visible=true;
}
//添加详细脚本
if(e.CommandName == "dateli")
{
string sSendId="";
DataView dvdata=(DataView)Session["dv1"];
foreach(DataRow row in dvdata.Table.Rows)
{
this.COMGfunction.StringAdd(ref sSendId,"",row["c_num"].ToString(),",");
}
this.Param_Open("corporation_reg_display");
this.Param_set("as_sendid",sSendId);
this.Param_set("as_pk",e.Item.Cells[1].Text);
SaveStatus();
this.CreatUserLogParentWindow("corporation_reg_display",this.o_str_FormUrl);//建立子窗口的父窗口数据值
Response.Redirect(this.o_str_DisplayFile1);
}
}
private void dbGridMain1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.FindControl("linkbDelete")!=null)
{
((LinkButton) e.Item.FindControl("linkbDelete")).Attributes.Add("onClick", "return confirm('您确实删除这条记录吗?');");
}
if(e.Item.Cells[4].Text=="01")
{
e.Item.Cells[4].Text="VIP客户";
}
else
{
if(e.Item.Cells[4].Text=="02")
{
e.Item.Cells[4].Text="普通客户";
}
else
{
e.Item.Cells[4].Text="临时客户";
}
}
if(e.Item.Cells[5].Text=="01")
{
e.Item.Cells[5].Text="大型企业";
}
else
{
if(e.Item.Cells[5].Text=="02")
{
e.Item.Cells[5].Text="中型企业";
}
else
{
e.Item.Cells[5].Text="小型企业";
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -