📄 companymanageedit.aspx.cs
字号:
/**************************************************************************************
作者:Created By zhouzheng.
创建日期:2002-11-11
修改者:
修改日期:
修改部分:
类功能:企业管理信息的修改功能。
****************************/
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;
using OI.DatabaseOper ;
namespace OI.Manage
{
/// <summary>
/// CompanyManageEdit 的摘要说明。
/// </summary>
public class CompanyManageEdit : OI.PageBase
{
protected System.Web.UI.WebControls.TextBox TextBoxCompanyName;
protected System.Web.UI.WebControls.TextBox TextBoxFictitiousPerson;
protected System.Web.UI.WebControls.TextBox TextBoxBiznature;
protected System.Web.UI.WebControls.TextBox TextBoxAssets;
protected System.Web.UI.WebControls.Label LabelWarning;
private int[] daysLeap={31,29,31,30,31,30,31,31,30,31,30,31};
private int[] daysCommon={31,28,31,30,31,30,31,31,30,31,30,31};
private string intCompanyID;
protected System.Web.UI.WebControls.TextBox TextBoxMemo;
protected System.Web.UI.WebControls.Label lCompanyID;
protected System.Web.UI.WebControls.DropDownList DropDownListIsRegout;
protected System.Web.UI.WebControls.Panel Panel1;
protected System.Web.UI.WebControls.DropDownList DropdownlistIsRegout;
protected System.Web.UI.WebControls.TextBox TextBoxRange;
protected System.Web.UI.WebControls.DropDownList DropDownListRegDateY;
protected System.Web.UI.WebControls.DropDownList DropDownListRegDateM;
protected System.Web.UI.WebControls.DropDownList DropDownListRegDateD;
protected System.Web.UI.WebControls.Panel Panel2;
protected System.Web.UI.WebControls.TextBox TextBoxRegOutDate;
protected System.Web.UI.WebControls.Panel Panel3;
protected System.Web.UI.WebControls.TextBox TextBoxRegDate;
protected System.Web.UI.WebControls.ImageButton ImageButtonEdit;
protected System.Web.UI.WebControls.ImageButton ImageButtonCancel;
private DatabaseConnect dc ;
private void Page_Load(object sender, System.EventArgs e)
{
if (Session["userid"]==null)
{
Response.Write ("<script>alert('超时,请重新登录');top.location.href='../userpass.aspx';</script>");
return ;
}
ImageButtonEdit.Attributes["onclick"]="return confirm('确定要保存修改吗')";
if(this.IsPostBack)
return;
dc = new DatabaseConnect();
intCompanyID =Request.QueryString ["CompanyID"].ToString ();
ViewState["intCompanyID"]=intCompanyID;
this.lCompanyID.Text=Request.QueryString ["CompanyID"].ToString ();
// 在此处放置用户代码以初始化页面
// ViewState["intCompanyID"]=CompanyID;
// this.Bind ();
this.initDate();
this.select();
}
/// <summary>
/// select 方法,从数据库中提取对应的数据
/// </summary>
private void select()
{
string sql="select * FROM CompanyManage WHERE CompanyID='"+intCompanyID+"'";
DataSet ds=dc.getBinding (sql,"CompanyManage");
TextBoxCompanyName.Text =ds.Tables[0].Rows[0]["CompanyName"].ToString ();
TextBoxFictitiousPerson.Text =ds.Tables[0].Rows[0]["FictitiousPerson"].ToString ();
TextBoxBiznature.Text =ds.Tables[0].Rows[0]["Biznature"].ToString ();
TextBoxAssets.Text =(Convert.ToInt32(ds.Tables[0].Rows[0]["Assets"])).ToString();
TextBoxRange.Text =ds.Tables[0].Rows[0]["Range"].ToString ();
TextBoxMemo.Text =ds.Tables[0].Rows[0]["Memo"].ToString ();
TextBoxRegDate.Text =string.Format("{0:yyyy-MM-dd}",ds.Tables[0].Rows[0]["RegDate"]);
if(ds.Tables[0].Rows[0]["RegOutDate"].ToString()!="")
{
Panel2.Visible=true;
Panel3.Visible=false;
TextBoxRegOutDate.Text =string.Format("{0:yyyy-MM-dd}",ds.Tables[0].Rows[0]["RegOutDate"]);
}
else
{
// TextBoxRegOutDate.Text ="";
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DropdownlistIsRegout.SelectedIndexChanged += new System.EventHandler(this.DropDownListIsRegout_SelectedIndexChanged);
this.ImageButtonEdit.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButtonEdit_Click);
this.ImageButtonCancel.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButtonCancel_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
/// <summary>
/// 清空各输入框,将各项的值设为默认值
/// </summary>
private void CleanUp()
{
this.TextBoxAssets.Text="";
this.TextBoxBiznature.Text="";
this.TextBoxCompanyName.Text="";
this.TextBoxFictitiousPerson.Text="";
this.TextBoxMemo.Text="";
this.TextBoxRange.Text="";
this.ImageButtonEdit.Visible=true;
// this.DropDownListIsRegout.Visible=true;
// this.DropDownListIsRegout.SelectedIndex=0;
this.TextBoxRegDate.Text="";
// this.TextBoxRegOutDate.Text="";
this.LabelWarning.Text="";
}
///summary>
/// 计算闰年
/// </summary>
/// <param name="year"></param>
/// <param name="month"></param>
/// <returns></returns>
private ArrayList getDays(int year,int month)
{
ArrayList dayArray=new ArrayList ();
if((year%4==0)&&(year%100!=0)||(year%400==0))
for(int i=0;i<daysLeap[month-1];i++)
dayArray.Add (i+1);
else
for(int i=0;i<daysCommon[month-1];i++)
dayArray.Add (i+1);
return dayArray;
}
/// <summary>
/// 获取年份
/// </summary>
/// <param name="initYear"></param>
/// <returns></returns>
private ArrayList getYear(int initYear)
{
ArrayList years=new ArrayList ();
DateTime tempYear=DateTime.Now ;
for(int i=initYear;i<=tempYear.Year;i++)
years.Add (i);
return years;
}
/// <summary>
/// 绑定注册时间,注销时间列表框
/// </summary>
private void initDate()
{
this.DropDownListRegDateY.DataSource=this.getYear(1943);
this.DropDownListRegDateY.SelectedIndex=0;
this.DropDownListRegDateY.DataBind();
}
/// <summary>
/// 如企业未注销则注销时间自动隐藏
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DropDownListIsRegout_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(this.DropdownlistIsRegout.SelectedIndex==0)
this.Panel1.Visible=false;
else
this.Panel1.Visible=true;
}
/// <summary>
/// 修改企业信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ImageButtonEdit_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
// Page.RegisterStartupScript("","<script>confirm('确定要保存修改吗');</script>") ;
dc=new DatabaseConnect();
string texCompanyName=this.TextBoxCompanyName.Text.Trim();
string texFictitiousPerson=this.TextBoxFictitiousPerson.Text.Trim();
string texBiznature=this.TextBoxBiznature.Text.Trim();
int tempAssets=Convert.ToInt32(TextBoxAssets.Text.Trim());
string texRange=this.TextBoxRange.Text.Trim();
string texMemo=this.TextBoxMemo.Text.Trim();
string texRegDate=this.TextBoxRegDate.Text.Trim();
string texRegOutDate=null;
char charIsRegout=Convert.ToChar(this.DropdownlistIsRegout.SelectedItem.Value);
if(texCompanyName!="")//检查企业名称是否为空
{
if(texFictitiousPerson!="")//检查法人代表是否为空
{
if(texBiznature!="")//检查企业性质否为空
{
if(tempAssets!=0)//检查企业资产是否为空
{
// try//判断企业资产是否大于零和是否为数字
// {
// double texpAssets=Convert.ToInt32(TextBoxAssets.Text.Trim());
// if(tempAssets<=0)
// {
// this.LabelWarning.Text="企业资产应大于零!";
// return;
// }
// }
// catch(System.Exception)
// {
// this.LabelWarning.Text="企业资产应为数字!";
// return;
// }
//如果该企业信息未注销
if(DropdownlistIsRegout.SelectedIndex==0)
{
string sql1="update CompanyManage set CompanyName='"+texCompanyName+"',FictitiousPerson='"+texFictitiousPerson+"',Biznature='"+texBiznature+"',Assets="+tempAssets+",Range='"+texRange+"',Memo='"+texMemo+"',RegDate='"+texRegDate+"'where CompanyID='"+this.lCompanyID.Text+"'";
dc.ExecuteSQL(sql1);
Response.Redirect("CompanyManages.aspx");
}
else
{
// //如果注销时间大于注册时间
// if(tempB<tempE)
// {
texRegOutDate=this.DropDownListRegDateY.SelectedItem.Value+"-"+
this.DropDownListRegDateM.SelectedItem.Value+"-"+
this.DropDownListRegDateD.SelectedItem.Value;
string sql2="update CompanyManage set CompanyName='"+texCompanyName+"',FictitiousPerson='"+texFictitiousPerson+"',Biznature='"+texBiznature+"',Assets="+tempAssets+",Range='"+texRange+"',Memo='"+texMemo+"',RegDate='"+texRegDate+"',RegOutDate='"+texRegOutDate+"',IsRegout=1 where CompanyID='"+this.lCompanyID.Text+"'";
dc.ExecuteSQL(sql2);
Response.Redirect("CompanyManages.aspx");
// }
// else
// {
// this.LabelWarning.Text="注册时间应小于注销时间!";
// }
}
}
else
{
this.LabelWarning.Text="请输入企业资产!";
}
}
else
{
this.LabelWarning.Text="请输入企业性质!";
}
}
else
{
this.LabelWarning.Text="请输入法人代表!";
}
}
else
{
this.LabelWarning.Text="请输入企业名称";
}
}
private void ImageButtonCancel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
intCompanyID=ViewState["intCompanyID"].ToString();
Response.Redirect("CompanyManageEdit.aspx?CompanyID="+intCompanyID+"");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -