📄 companymanageadd.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>
/// CompanyManageAdd 的摘要说明。
/// </summary>
public class CompanyManageAdd : 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;
private int[] daysCommon={31,28,31,30,31,30,31,31,30,31,30,31};
private int[] daysLeap={31,29,31,30,31,30,31,31,30,31,30,31};
protected System.Web.UI.WebControls.DropDownList DropDownListRegDateD;
protected System.Web.UI.WebControls.DropDownList DropDownListRegDateM;
protected System.Web.UI.WebControls.DropDownList DropDownListRegDateY;
protected System.Web.UI.WebControls.TextBox TextBoxRange;
protected System.Web.UI.WebControls.TextBox TextBoxMemo;
protected System.Web.UI.WebControls.Label LabelWarning;
protected System.Web.UI.WebControls.RangeValidator RangeValidatorAssets;
protected System.Web.UI.WebControls.ImageButton ImageButtonSave;
protected System.Web.UI.WebControls.ImageButton ImageButtonCancel;
private DatabaseOper.DatabaseConnect dc = new DatabaseOper.DatabaseConnect();
private void Page_Load(object sender, System.EventArgs e)
{
if (Session["userid"]==null)
{
Response.Write ("<script>alert('超时,请重新登录');top.location.href='../userpass.aspx';</script>");
return ;
}
ImageButtonSave.Attributes ["onclick"]="return Check();";
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
this.initDate();
}
}
/// <summary>
/// 清空各输入框,将各项的值设为默认值
/// </summary>
private void CleanUp()
{
this.TextBoxAssets.Text="";
this.TextBoxBiznature.Text="";
this.TextBoxCompanyName.Text="";
this.TextBoxFictitiousPerson.Text="";
this.TextBoxMemo.Text="";
this.TextBoxRange.Text="";
// this.DropDownListRegDateY.Items.Clear();
// this.DropDownListRegDateM.ClearSelection();
// this.DropDownListRegDateD.ClearSelection();
// this.DropDownListRegDateY.Items.Add("请选择");
this.LabelWarning.Text="";
this.ImageButtonSave.Visible=true;
}
/// <summary>
/// 激活保存按钮及各输入框
/// </summary>
private void Stimulate()
{
this.TextBoxAssets.ReadOnly=false;
this.TextBoxBiznature.ReadOnly=false;
this.TextBoxCompanyName.ReadOnly=false;
this.TextBoxFictitiousPerson.ReadOnly=false;
this.TextBoxMemo.ReadOnly=false;
this.TextBoxRange.ReadOnly=false;
this.DropDownListRegDateY.Enabled=true;
this.DropDownListRegDateM.Enabled=true;
this.DropDownListRegDateD.Enabled=true;
this.ImageButtonSave.Visible=false;
}
/// <summary>
/// 恢复各项的初始属性
/// </summary>
private void Complete()
{
this.TextBoxAssets.ReadOnly=true;
this.TextBoxBiznature.ReadOnly=true;
this.TextBoxCompanyName.ReadOnly=true;
this.TextBoxFictitiousPerson.ReadOnly=true;
this.TextBoxMemo.ReadOnly=true;
this.TextBoxRange.ReadOnly=true;
this.DropDownListRegDateY.Enabled=false;
this.DropDownListRegDateM.Enabled=false;
this.DropDownListRegDateD.Enabled=false;
this.ImageButtonSave.Visible=true;
}
/// <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=tempYear.Year-initYear;i<=tempYear.Year;i++)
years.Add (i);
return years;
}
/// <summary>
/// 绑定注册时间
/// </summary>
private void initDate()
{
this.DropDownListRegDateY.DataSource=this.getYear(60);
this.DropDownListRegDateY.SelectedIndex=0;
this.DropDownListRegDateY.DataBind();
this.DropDownListRegDateM.SelectedIndex=0;
// this.DropDownListRegDateD.DataSource =this.getDays(Convert.ToInt32 (this.DropDownListRegDateY.SelectedItem .Value .Trim ()),
// Convert.ToInt32 (this.DropDownListRegDateM.SelectedItem.Value .Trim ()));
this.DropDownListRegDateD.DataBind ();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.ImageButtonSave.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButtonSave_Click);
this.ImageButtonCancel.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButtonCancel_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
/// <summary>
/// 保存企业信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ImageButtonSave_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if(!this.IsValid)
return;
//赋值
dc=new DatabaseConnect();
string texCompanyName=this.TextBoxCompanyName.Text.Trim();
string texFictitiousPerson=this.TextBoxFictitiousPerson.Text.Trim();
string texBiznature=this.TextBoxBiznature.Text.Trim();
// double texAssets=0;
// if(!Assets.Text .Trim ().Equals (""))
// texAssets=Convert.ToDouble (Assets.Text .Trim ())*10000;
int texAssets=Convert.ToInt32(this.TextBoxAssets.Text.Trim());
string texRange=this.TextBoxRange.Text.Trim();
string texMemo=this.TextBoxMemo.Text.Trim();
string strRegDate=this.DropDownListRegDateY.SelectedItem.Value+"-"+
this.DropDownListRegDateM.SelectedItem.Value+"-"+
this.DropDownListRegDateD.SelectedItem.Value;
//提取当前时间
DateTime strChangeDate=DateTime.Now;
//提取当前用户ID
int intUserID=int.Parse(this.User.Identity.Name);
//获取各项的值
if(texCompanyName!="")//检查企业名称是否为空
{
if(texFictitiousPerson!="")//检查法人代表是否为空
{
if(texBiznature!="")//检查企业性质否为空
{
if(texAssets>=0)
{
// try//判断企业资产是否大于零和是否为数字
// {
// double tempAssets=Convert.ToInt32(TextBoxAssets.Text.Trim());
// if(tempAssets<=0)
// {
// this.LabelWarning.Text="企业资产应大于零";
// return;
// }
// }
// catch(System.Exception)
// {
// this.LabelWarning.Text="企业资产应为数字";
// return;
// }
string sql="insert into CompanyManage(CompanyName,FictitiousPerson,Biznature,Assets,RegDate,Range,Memo,IsRegout,ChangeDate,UserID)"+
"values('"+texCompanyName+"','"+texFictitiousPerson+"','"+texBiznature+"',"+texAssets+",'"+strRegDate+"','"+texRange+"','"+texMemo+"','0','"+strChangeDate+"','"+intUserID+"')";
dc.addData (sql);
this.Complete();
this.LabelWarning.Text="增加企业信息成功";
//
// int.Parse(this.User.Identity.Name)
}
else
{
this.LabelWarning.Text="请输入企业资产";
}
}
else
{
this.LabelWarning.Text="企业性质不能为空";
}
}
else
{
this.LabelWarning.Text="法人代表不能为空";
}
}
else
{
this.LabelWarning.Text="企业名称不能为空";
}
}
/// <summary>
/// 清空文本框中的内容
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ImageButtonCancel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
this.CleanUp();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -