using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Data;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using System.Data.OleDb;
//内容
public SqlConnection cn;
private SqlDataAdapter ada;
private DataSet ds;
public DataRow dr;
public SqlTransaction tran;
public OleDbConnection ocn;
public OleDbDataAdapter oda;
//**********************************>> 基本数据库操作篇 <<**********************************//
/// <summary>
/// 打开数据库
/// </summary>
public void Open()
{
cn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
cn.Open();
}
/// <summary>
/// 关闭数据库
/// </summary>
public void Close()
{
if (cn != null)
cn.Close();
}
/// <summary>
/// 打开OleDb连接
/// </summary>
/// <param name="name">连接字符串</param>
public void OOpen(string name)
{
ocn = new OleDbConnection(name);
ocn.Open();
}
/// <summary>
/// 关闭OleDb连接
/// </summary>
public void OClose()
{
if(ocn != null)
ocn.Close();
}
/// <summary>
/// 返回DataView 视图
/// </summary>
/// <param name="str_sql">sql语句</param>
/// <param name="str_tablename">sql表名</param>
/// <returns></returns>
public DataView mydv(string str_sql,string str_tablename)
{
Open();
SqlDataAdapter sda = new SqlDataAdapter(str_sql,cn);
DataSet ds = new DataSet();
sda.Fill(ds,str_tablename);
DataView mydv = ds.Tables[str_tablename].DefaultView;
Close();
return mydv;
}
/// <summary>
/// 返回OleDb DataView 视图
/// </summary>
/// <param name="o_sql">oledb连接字符串</param>
/// <param name="str_sqlo">sql语句</param>
/// <param name="str_tablename">sql表名</param>
/// <returns></returns>
public DataView omydv(string o_sql,string str_sql,string str_tablename)
{
OOpen(o_sql);
OleDbDataAdapter osda = new OleDbDataAdapter(str_sql,ocn);
DataSet ds = new DataSet();
osda.Fill(ds,str_tablename);
DataView mydv = ds.Tables[str_tablename].DefaultView;
OClose();
return mydv;
}
/// <summary>
/// 返回一个SqlParameter实例
/// </summary>
/// <param name="ParamName"></param>
/// <param name="Value"></param>
/// <returns></returns>
public SqlParameter MakeParam(string ParamName,object Value)
{
return new SqlParameter(ParamName, Value);
}
/// <summary>
/// 调用存储过程创建一个SqlCommand对象
/// </summary>
/// <param name="procName">存储过程</param>
/// <param name="prams">给存储过程传递传输SqlParameter对象</param>
/// <returns></returns>
private SqlCommand CreateCommand(string procName, SqlParameter[] prams)
{
Open();
SqlCommand cmd = new SqlCommand(procName, cn);
cmd.CommandType = CommandType.StoredProcedure;
if (prams != null)
{
foreach (SqlParameter parameter in prams)
cmd.Parameters.Add(parameter);
}
cmd.Parameters.Add(
new SqlParameter("ReturnValue", SqlDbType.Int, 4,
ParameterDirection.ReturnValue, false, 0, 0,
string.Empty, DataRowVersion.Default, null));
return cmd;
}
/// <summary>
/// 执行存储过程
/// </summary>
/// <param name="procName">存储过程名称</param>
/// <param name="prams">给存储过程传递传输SqlParameter对象</param>
/// <returns></returns>
private void RunProc(string procName, SqlParameter[] prams)
{
SqlCommand cmd = CreateCommand(procName, prams);
cmd.ExecuteNonQuery();
this.Close();
}
/// <summary>
/// 执行存储过程
/// </summary>
/// <param name="procName">存储过程名称</param>
/// <param name="prams">给存储过程传递传输SqlParameter对象</param>
/// <param name="dataReader">输出一个DataReader对象</param>
public void RunProc(string procName, SqlParameter[] prams, out SqlDataReader dataReader)
{
SqlCommand cmd = CreateCommand(procName, prams);
dataReader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
}
/// <summary>
/// 获得DataSet对象
/// </summary>
/// <param name="str_Sql">SQL语句</param>
/// <returns></returns>
public DataSet GetDs(string str_Sql)
{
Open();
SqlDataAdapter Ada = new SqlDataAdapter(str_Sql,cn);
DataSet ds = new DataSet();
Ada.Fill(ds);
Close();
return ds;
}
/// <summary>
/// 获得OleDb的DataSet对象
/// </summary>
/// <param name="str_Sql">SQL语句</param>
/// <param name="o_sql">sql连接字符串</param>
/// <returns></returns>
public DataSet GetODs(string o_sql,string str_Sql)
{
OOpen(o_sql);
oda = new OleDbDataAdapter(str_Sql,ocn);
ds = new DataSet();
oda.Fill(ds);
OClose();
return ds;
}
/// <summary>
/// 获得DataTable对象
/// </summary>
/// <param name="str_Sql">SQL语句</param>
/// <returns></returns>
public DataTable GetTable(string str_Sql)
{
return GetDs(str_Sql).Tables[0];
}
/// <summary>
/// 获得DataTable对象
/// </summary>
/// <param name="tablename">内存表ID</param>
/// <param name="str_Sql">SQL语句</param>
/// <returns></returns>
public DataTable GetTable(string tablename,string str_Sql)
{
return GetDs(str_Sql).Tables[tablename];
}
/// <summary>
/// 获得SqlDataReader对象
/// </summary>
/// <param name="str_Sql">sql语句</param>
/// <returns></returns>
public SqlDataReader GetDataReader(string str_Sql)
{
Open();
SqlCommand cmd = new SqlCommand(str_Sql,cn);
SqlDataReader dataReader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
return dataReader;
}
/// <summary>
/// 获得OledbDataReader对象
/// </summary>
/// <param name="str_Sql">sql语句</param>
/// <returns></returns>
public OleDbDataReader GetODataReader(string o_sql,string str_Sql)
{
OOpen(o_sql);
OleDbCommand ocmd = new OleDbCommand(str_Sql,ocn);
OleDbDataReader dataReader = ocmd.ExecuteReader();
return dataReader;
}
/// <summary>
/// 执行Sql语句
/// </summary>
/// <param name="str_Sql">Sql语句</param>
public void RunSql(string str_Sql)
{
Open();
SqlCommand cmd = new SqlCommand(str_Sql,cn);
cmd.ExecuteNonQuery();
Close();
}
/// <summary>
/// 执行OledbSql语句
/// </summary>
/// <param name="str_Sql">Sql语句</param>
/// <param name="o_sql">数据库连接字符串</param>
public void RunOSql(string o_sql,string str_Sql)
{
OOpen(o_sql);
OleDbCommand ocmd = new OleDbCommand(str_Sql,ocn);
ocmd.ExecuteNonQuery();
OClose();
}
//**********************************>> 数据库操作篇(包括添加Add,修改Edit,删除Del,详细Detail) <<**********************************//
/// <summary>
/// 读出详细信息赋给相应控件,控件包括Label,Text,RichTextBox,Calendar
/// </summary>
/// <param name="fileds">字段数组,比如:string[] fileds={"title","content","Derivation","Dates"};</param>
/// <param name="ctrls">控件数组,比如:Control[] ctrls={txt_Title,txt_Content,txt_Derivation,cdr_Dates};</param>
/// <param name="str_Sql">SQL语句</param>
public void Detail(string [] fileds,Control [] ctrls,string str_Sql)
{
SqlDataReader dr=GetDataReader(str_Sql);
int i=0;
while (dr.Read())
{
foreach (Control ctrl in ctrls)
{
if( ctrl is TextBox )
{
try
{
if (GetStrAppearTime(dr[fileds[i]].ToString(),"-")==2)
{
((TextBox)ctrl).Text=Convert.ToDateTime(dr[fileds[i]].ToString()).ToShortDateString();
}
else
{
((TextBox)ctrl).Text=dr[fileds[i]].ToString();
}
}
catch
{
((TextBox)ctrl).Text=dr[fileds[i]].ToString();
}
}
if( ctrl is Label )
{
try
{
((Label)ctrl).Text=Convert.ToDateTime(dr[fileds[i]].ToString()).ToShortDateString();
}
catch
{
((Label)ctrl).Text=dr[fileds[i]].ToString();
}
}
if (ctrl is WFNetCtrl.RichTextBox)
{
try
{
((WFNetCtrl.RichTextBox)ctrl).Text=Convert.ToDateTime(dr[fileds[i]].ToString()).ToShortDateString();
}
catch
{
((WFNetCtrl.RichTextBox)ctrl).Text=dr[fileds[i]].ToString();
}
}
if (ctrl is WFNetCtrl.Calendar)
{
try
{
((WFNetCtrl.Calendar)ctrl).Text=Convert.ToDateTime(dr[fileds[i]].ToString()).ToShortDateString();
}
catch
{
((WFNetCtrl.Calendar)ctrl).Text=dr[fileds[i]].ToString();
}
}
i=i+1;
}
break;
}
dr.Close();
}
/// <summary>
/// 读出详细信息赋给相应控件以及预先定义好的变量,控件包括Label,Text,RichTextBox,Calendar
/// </summary>
/// <param name="fileds">字段数组,比如:string[] fileds={"title","content","Derivation","Dates"};</param>
/// <param name="ctrls">控件数组,比如:Control[] ctrls={txt_Title,txt_Content,txt_Derivation,cdr_Dates};</param>
/// <param name="ref_fileds">ref输出字段数组</param>
/// <param name="str_Sql">SQL语句</param>
public void Detail(string [] fileds,Control [] ctrls,string [] ref_fileds,ref string [] ref_ctrls, string str_Sql)
{
SqlDataReader dr=GetDataReader(str_Sql);
int i=0;
while (dr.Read())
{
foreach (Control ctrl in ctrls)
{
if( ctrl is TextBox )
{
try
{
if (GetStrAppearTime(dr[fileds[i]].ToString(),"-")==2)
{
((TextBox)ctrl).Text=Convert.ToDateTime(dr[fileds[i]].ToString()).ToShortDateString();
}
else
{
((TextBox)ctrl).Text=dr[fileds[i]].ToString();
}
}
catch
{
((TextBox)ctrl).Text=dr[fileds[i]].ToString();
}
}
if( ctrl is Label )
{
try
{
((Label)ctrl).Text=Convert.ToDateTime(dr[fileds[i]].ToString()).ToShortDateString();
}
catch
{
((Label)ctrl).Text=dr[fileds[i]].ToString();
}
}
if (ctrl is WFNetCtrl.RichTextBox)
{
try
{
((WFNetCtrl.RichTextBox)ctrl).Text=Convert.ToDateTime(dr[fileds[i]].ToString()).ToShortDateString();
}
catch
{
((WFNetCtrl.RichTextBox)ctrl).Text=dr[fileds[i]].ToString();
}
}
if (ctrl is WFNetCtrl.Calendar)
{
try
{
((WFNetCtrl.Calendar)ctrl).Text=Convert.ToDateTime(dr[fileds[i]].ToString()).ToShortDateString();
}
catch
{
((WFNetCtrl.Calendar)ctrl).Text=dr[fileds[i]].ToString();
}
}
i=i+1;
}
for (int j=0;j<ref_fileds.Length;j++)
{
ref_ctrls[j]=dr[ref_fileds[j]].ToString();
}
break;
}
dr.Close();
}
/// <summary>
/// 读出详细信息赋给预先定义好的变量数组
/// </summary>
/// <param name="ref_fileds">字段数组,比如:string[] ref_fileds={"name","age"}</param>
/// <param name="ref_Variables">变量数组,string[] ref_Variables={"",""}</param>
/// <param name="str_Sql">SQL语句</param>
public void Detail(string [] ref_fileds,ref string [] ref_Variables, string str_Sql)
{
SqlDataReader dr=GetDataReader(str_Sql);
while (dr.Read())
{
for (int j=0;j<ref_fileds.Length;j++)
{
ref_Variables[j]=dr[ref_fileds[j]].ToString();
}
break;
}
dr.Close();
}
/// <summary>
/// 获得表记录数
/// </summary>
/// <param name="table_name">表名或者表名+条件,GetRsCount("t_user where id="+Request["id"])</param>
/// <returns></returns>
public int GetRsCount(string table_name)
{
string strSql;
int intCount;
Open();
strSql="select count(*) from "+table_name;
SqlCommand cmd=new SqlCommand(strSql,cn);
intCount=(int)cmd.ExecuteScalar();
cn.Close();
return intCount;
}
/// <summary>
/// 获得单个int类型字段总和
/// </summary>
/// <param name="field">字段</param>
/// <param name="table_name">表名或者表名+条件,GetFiledSum("id","t_user where id="+Request["id"])</param>
/// <returns></returns>
public string GetFiledSum(string field,string table_name)
{
string SumValue;
Open();
SqlCommand cmd=new SqlCommand("select sum("+field+") as s from "+table_name,cn);
SumValue=cmd.ExecuteScalar().ToString();
cn.Close();
return SumValue;
}
public string GetFiledSum(string field)
{
string SumValue;
Open();
SqlCommand cmd=new SqlCommand(field,cn);
SumValue=cmd.ExecuteScalar().ToString();
cn.Close();
return SumValue;
}
/// <summary>
/// 获得单个字段值
/// </summary>
/// <param name="str_Sql">Sql语句</param>
/// <returns></returns>
public string GetFiledValue(string str_Sql)
{
string str;
Open();
SqlCommand cmd=new SqlCommand(str_Sql,cn);
str=cmd.ExecuteScalar().ToString();
cn.Close();
return str;
}
/// <summary>
/// 获得表记录数
/// </summary>
/// <param name="table_name">表名或者表名+条件,GetRsCount("t_user where id="+Request["id"])</param>
/// <returns></returns>
public int GetMaxId(string filed,string table_name)
{
string strSql;
int intCount;
Open();
strSql="select max("+filed+") from "+table_name;
SqlCommand cmd=new SqlCommand(strSql,cn);
object obj=cmd.ExecuteScalar();
if (obj==System.DBNull.Value)
{
intCount=1;
}
else
{
intCount = Convert.ToInt32(cmd.ExecuteScalar())+1;
}
cn.Close();
return intCount;
}
/// <summary>
/// 通过SqlCommandBuilder对象增加数据库记录
/// </summary>
/// <param name="sql">Select-SQL语句</param>
public void Builder(string str_Sql)
{
Open();
ada=new SqlDataAdapter(str_Sql,cn);
SqlCommandBuilder myCommandBuilder=new SqlCommandBuilder(ada);
ds=new DataSet();
ada.Fill(ds);
dr=ds.Tables[0].NewRow();
}
/// <summary>
/// 关闭SqlCommandBuilder对象
/// </summary>
public void BuilderClose()
{
ds.Tables[0].Rows.Add(dr);
ada.Update(ds); // 更新数据库
cn.Close(); // 关闭数据库
ds.Clear(); // 清空DataSet对象
}
/// <summary>
/// 通过SqlCommandBuilder对象修改数据库记录
/// </summary>
/// <param name="sql">Select-SQL语句</param>
public void BuilderEdit(string str_Sql)
{
Open();
ada=new SqlDataAdapter(str_Sql,cn);
SqlCommandBuilder myCommandBuilder=new SqlCommandBuilder(ada);
ds=new DataSet();
ada.Fill(ds);
dr=ds.Tables[0].Rows[0];
}
/// <summary>
/// 关闭SqlCommandBuilder对象
/// </summary>
public void BuilderEditClose()
{
ada.Update(ds); // 更新数据库
cn.Close(); // 关闭数据库
ds.Clear(); // 清空DataSet对象
}
//**********************************>> 事务处理篇 <<**********************************//
/// <summary>
/// 开始事务
/// </summary>
public void TranBegin()
{
Open();
tran=cn.BeginTransaction();
}
/// <summary>
/// 结束事务
/// </summary>
public void TranEnd()
{
tran.Commit(); // 结束事务
if (cn!=null)
{
cn.Dispose(); // 关闭数据库
cn.Close(); // 关系数据库
}
if (ds!=null)
{
ds.Clear();
}
}
public SqlDataReader TranGetDataReader(string str_Sql)
{
Open();
SqlCommand cmd=new SqlCommand(str_Sql,cn);
SqlDataReader dr=cmd.ExecuteReader();
return dr;
}
public DataSet TranGetDs(string str_Sql)
{
Open();
SqlDataAdapter Ada = new SqlDataAdapter(str_Sql,cn);
Ada.SelectCommand.Transaction=tran;
DataSet ds = new DataSet();
Ada.Fill(ds);
//cn.Close();
return ds;
}
public DataTable TranGetTable(string str_Sql)
{
return TranGetDs(str_Sql).Tables[0];
}
/// <summary>
/// 获得表记录数
/// </summary>
/// <param name="table_name">表名或者表名+条件,GetRsCount("t_user where id="+Request["id"])</param>
/// <returns></returns>
public int TranGetRsCount(string table_name)
{
string strSql;
int intCount;
strSql="select count(*) from "+table_name;
SqlCommand cmd=new SqlCommand(strSql,cn);
cmd.Transaction=tran;
intCount=(int)cmd.ExecuteScalar();
return intCount;
}
/// <summary>
/// 获得单个int类型字段总和
/// </summary>
/// <param name="field">字段</param>
/// <param name="table_name">表名或者表名+条件,GetFiledSum("id","t_user where id="+Request["id"])</param>
/// <returns></returns>
public string TranGetFiledSum(string field,string table_name)
{
string SumValue;
SqlCommand cmd=new SqlCommand("select sum("+field+") as s from "+table_name,cn);
cmd.Transaction=tran;
SumValue=cmd.ExecuteScalar().ToString();
return SumValue;
}
/// <summary>
/// 获得单个字段值
/// </summary>
/// <param name="str_Sql">Sql语句</param>
/// <returns></returns>
public string TranGetFiledValue(string str_Sql)
{
string str;
SqlCommand cmd=new SqlCommand(str_Sql,cn);
cmd.Transaction=tran;
str=cmd.ExecuteScalar().ToString();
return str;
}
/// <summary>
/// 执行Sql语句
/// </summary>
/// <param name="str_Sql">Sql语句</param>
public void TranRunSql(string str_Sql)
{
SqlCommand cmd = new SqlCommand(str_Sql,cn);
cmd.Transaction=tran;
cmd.ExecuteNonQuery();
}
/// <summary>
/// 通过SqlCommandBuilder对象增加数据库记录
/// </summary>
/// <param name="sql">Select-SQL语句</param>
public void TranBuilder(string str_Sql)
{
ada=new SqlDataAdapter(str_Sql,cn);
ada.SelectCommand.Transaction=tran;
SqlCommandBuilder myCommandBuilder=new SqlCommandBuilder(ada);
ds=new DataSet();
ada.Fill(ds);
dr=ds.Tables[0].NewRow();
}
/// <summary>
/// 关闭SqlCommandBuilder对象
/// </summary>
public void TranBuilderClose()
{
ds.Tables[0].Rows.Add(dr);
ada.Update(ds); // 更新数据库
}
/// <summary>
/// 通过SqlCommandBuilder对象修改数据库记录
/// </summary>
/// <param name="sql">Select-SQL语句</param>
public void TranBuilderEdit(string str_Sql)
{
ada=new SqlDataAdapter(str_Sql,cn);
ada.SelectCommand.Transaction=tran;
SqlCommandBuilder myCommandBuilder=new SqlCommandBuilder(ada);
ds=new DataSet();
ada.Fill(ds);
dr=ds.Tables[0].Rows[0];
}
/// <summary>
/// 关闭SqlCommandBuilder对象
/// </summary>
public void TranBuilderEditClose()
{
ada.Update(ds); // 更新数据库
}
/// <summary>
/// 事务回滚
/// </summary>
public void TranRollback()
{
tran.Rollback(); // 数据库回滚
cn.Dispose(); // 关闭数据库
cn.Close(); // 关系数据库
}
//**********************************>> 控件操作篇 <<**********************************//
/// <summary>
/// 绑定DataGrid,Repeat,DataList控件不分页
/// </summary>
/// <param name="str_Sql">SQL语句</param>
/// <param name="ctl_Listctl">DataGrid,Repeat,DataList控件id</param>
public void BindCtrl(string str_Sql,Control ctl_Listctl)
{
DataSet ds=GetDs(str_Sql);
if (ctl_Listctl is Repeater)
{
((Repeater)ctl_Listctl).DataSource=ds.Tables[0].DefaultView;
((Repeater)ctl_Listctl).DataBind();
}
if (ctl_Listctl is DataList)
{
((DataList)ctl_Listctl).DataSource=ds.Tables[0].DefaultView;
((DataList)ctl_Listctl).DataBind();
}
if (ctl_Listctl is DataGrid)
{
((DataGrid)ctl_Listctl).DataSource=ds.Tables[0].DefaultView;
((DataGrid)ctl_Listctl).DataBind();
}
}
/// <summary>
/// 绑定DataGrid,Repeat,DataList控件并分页
/// </summary>
/// <param name="fileds">参数名,其中两个参数是必须的,比如:{"PageIndex","PageSize"},如果是条件查询分页,后面应加上条件字段</param>
/// <param name="texts">和fileds相对应,比如:{AspNetPager1.CurrentPageIndex.ToString(),AspNetPager1.PageSize.ToString()},如果是条件查询分页,后面应加上条件字段值</param>
/// <param name="procName">存储过程名称</param>
/// <param name="ctl_Listctl">DataGrid,Repeat,DataList控件id值</param>
/// <param name="AspNetPager1">分页控件AspNetPager控件id值</param>
public void BindCtrl(string[] fileds,string[] texts,string procName,Control ctl_Listctl,WFNetCtrl.AspNetPager AspNetPager1)
{
SqlDataReader dr;
Open();
SqlCommand cmd = new SqlCommand(procName, cn);
cmd.CommandType = CommandType.StoredProcedure;
for (int i=0;i<fileds.Length;i++)
{
SqlParameter parameter=new SqlParameter("@"+fileds[i],texts[i]);
cmd.Parameters.Add(parameter);
}
dr=cmd.ExecuteReader();
if (ctl_Listctl is Repeater)
{
((Repeater)ctl_Listctl).DataSource=dr;
((Repeater)ctl_Listctl).DataBind();
}
if (ctl_Listctl is DataList)
{
((DataList)ctl_Listctl).DataSource=dr;
((DataList)ctl_Listctl).DataBind();
}
if (ctl_Listctl is DataGrid)
{
((DataGrid)ctl_Listctl).DataSource=dr;
((DataGrid)ctl_Listctl).DataBind();
}
AspNetPager1.CustomInfoText="当前页/总页数:"+AspNetPager1.CurrentPageIndex+"/"+AspNetPager1.PageCount+",每页记录:"+AspNetPager1.PageSize;
this.Close();
}
/// <summary>
/// /// 绑定DropDownList,CheckBoxList,RadioButtonList,ListBox等列表控件
/// </summary>
/// <param name="str_Sql">SQL语句</param>
/// <param name="id">数据库表字段,一般为该表的主键</param>
/// <param name="name">数据库表字段,控将显示值</param>
/// <param name="listctrl">控将ID值</param>
public void BindCtrl(string id,string name,string str_Sql,Control listctrl)
{
DataTable dt=GetTable(str_Sql);
//===DropDownList===
if (listctrl is DropDownList)
{
for (int i=0;i<dt.Rows.Count;i++)
{
ListItem it=new ListItem(dt.Rows[i][name].ToString(),dt.Rows[i][id].ToString());
((DropDownList)listctrl).Items.Add(it);
}
}
//===CheckBoxList===
if (listctrl is CheckBoxList)
{
for (int i=0;i<dt.Rows.Count;i++)
{
ListItem it=new ListItem(dt.Rows[i][name].ToString(),dt.Rows[i][id].ToString());
((CheckBoxList)listctrl).Items.Add(it);
}
}
//===RadioButtonList===
if (listctrl is RadioButtonList)
{
for (int i=0;i<dt.Rows.Count;i++)
{
ListItem it=new ListItem(dt.Rows[i][name].ToString(),dt.Rows[i][id].ToString());
((RadioButtonList)listctrl).Items.Add(it);
}
}
//===ListBox===
if (listctrl is ListBox)
{
for (int i=0;i<dt.Rows.Count;i++)
{
ListItem it=new ListItem(dt.Rows[i][name].ToString(),dt.Rows[i][id].ToString());
((ListBox)listctrl).Items.Add(it);
}
}
dt.Clear();
}
/// <summary>
/// 通过某值选中DropDownList,CheckBoxList,RadioButtonList,ListBox控件要显示的值
/// </summary>
/// <param name="strValueField">要选中的值</param>
/// <param name="listctrl">DropDownList,CheckBoxList,RadioButtonList,ListBox控件Id值</param>
public void SelCtrl(string strValueField,Control listctrl)
{
if (listctrl is DropDownList)
{
//===DropDownList===
((DropDownList)listctrl).Items[0].Selected=false;
for (int i=0;i<((DropDownList)listctrl).Items.Count;i++)
{
if (strValueField==((DropDownList)listctrl).Items[i].Value)
{
((DropDownList)listctrl).Items[i].Selected=true;
break;
}
}
}
//===CheckBoxList===
if (listctrl is CheckBoxList)
{
for (int i=0;i<((CheckBoxList)listctrl).Items.Count;i++)
{
if (strValueField.IndexOf(((CheckBoxList)listctrl).Items[i].Value)!=-1)
{
((CheckBoxList)listctrl).Items[i].Selected=true;
}
}
}
//===RadioButtonList===
if (listctrl is RadioButtonList)
{
((RadioButtonList)listctrl).Items[0].Selected=false;
for (int i=0;i<((RadioButtonList)listctrl).Items.Count;i++)
{
if (strValueField==((RadioButtonList)listctrl).Items[i].Value)
{
((RadioButtonList)listctrl).Items[i].Selected=true;
break;
}
}
}
//===ListBox===
if (listctrl is ListBox)
{
for (int i=0;i<((ListBox)listctrl).Items.Count;i++)
{
if (strValueField.IndexOf(((ListBox)listctrl).Items[i].Value)!=-1)
{
((ListBox)listctrl).Items[i].Selected=true;
}
}
}
}
/// <summary>
/// 绑定DropDownList,CheckBoxList,RadioButtonList,ListBox控件并选中它值
/// </summary>
/// <param name="strValueField">要选中的值</param>
/// <param name="id">数据库表字段,一般为该表的主键</param>
/// <param name="name">数据库表字段,控将显示值</param>
/// <param name="str_Sql">SQL语句</param>
/// <param name="listctrl">DropDownList,CheckBoxList,RadioButtonList,ListBox控件id值</param>
public void SelCtrl(string strValueField,string id,string name,string str_Sql,Control listctrl)
{
// ===绑定列表控件===
BindCtrl(id,name,str_Sql,listctrl);
//===DropDownList===
if (listctrl is DropDownList)
{
((DropDownList)listctrl).Items[0].Selected=false;
for (int i=0;i<((DropDownList)listctrl).Items.Count;i++)
{
if (strValueField==((DropDownList)listctrl).Items[i].Value)
{
((DropDownList)listctrl).Items[i].Selected=true;
break;
}
}
}
//===CheckBoxList===
if (listctrl is CheckBoxList)
{
for (int i=0;i<((CheckBoxList)listctrl).Items.Count;i++)
{
if (strValueField.IndexOf(((CheckBoxList)listctrl).Items[i].Value)!=-1)
{
((CheckBoxList)listctrl).Items[i].Selected=true;
}
}
}
//===RadioButtonList===
if (listctrl is RadioButtonList)
{
((RadioButtonList)listctrl).Items[0].Selected=false;
for (int i=0;i<((RadioButtonList)listctrl).Items.Count;i++)
{
if (strValueField==((RadioButtonList)listctrl).Items[i].Value)
{
((RadioButtonList)listctrl).Items[i].Selected=true;
break;
}
}
}
//===ListBox===
if (listctrl is ListBox)
{
for (int i=0;i<((ListBox)listctrl).Items.Count;i++)
{
if (strValueField.IndexOf(((ListBox)listctrl).Items[i].Value)!=-1)
{
((ListBox)listctrl).Items[i].Selected=true;
}
}
}
}
/// <summary>
/// 通过一复选框全选全取消某ID值复选框
/// </summary>
/// <param name="cb_Id">复选框组ID</param>
/// <param name="cb_SelectCancel">控制复选框</param>
/// <param name="ctrl">DataGrid,Repeat,DataList控件id</param>
public void ChcekAllSel(string cb_Id,CheckBox cb_SelectCancel,Control ctrl)
{
if (ctrl is Repeater)
{
for (int i=0;i<((Repeater)ctrl).Items.Count;i++)
{
CheckBox myCheckBox=(CheckBox)((Repeater)ctrl).Items[i].FindControl(cb_Id);
if(cb_SelectCancel.Checked==true)
{
myCheckBox.Checked=true;
}
else
{
myCheckBox.Checked=false;
}
}
}
//===DataList===
if (ctrl is DataList)
{
for (int i=0;i<((DataList)ctrl).Items.Count;i++)
{
CheckBox myCheckBox=(CheckBox)((DataList)ctrl).Items[i].FindControl(cb_Id);
if(cb_SelectCancel.Checked==true)
{
myCheckBox.Checked=true;
}
else
{
myCheckBox.Checked=true;
}
}
}
//===DataGrid===
if (ctrl is DataGrid)
{
for (int i=0;i<((DataGrid)ctrl).Items.Count;i++)
{
CheckBox myCheckBox=(CheckBox)((DataGrid)ctrl).Items[i].FindControl(cb_Id);
if(cb_SelectCancel.Checked==true)
{
myCheckBox.Checked=true;
}
else
{
myCheckBox.Checked=true;
}
}
}
}
/// <summary>
/// 获得Repeater,DataGrid,DataList控件所有选中Id值,形式"id=1 and id=3"
/// </summary>
/// <param name="id">表的标识字段,比如:"id"</param>
/// <param name="cb_Id">复选框Id,比如"cb_Id"</param>
/// <param name="lbl_Id">Label的Id,比如"lbl_Id"</param>
/// <param name="ctrl">Repeater,DataGrid,DataList控件Id值</param>
/// <param name="Type">类型,标识字段分string,int两种类型</param>
/// <returns></returns>
public string GetCtrlId(string id,string cb_Id,string lbl_Id,Control ctrl,string Type)
{
string str_Where="";
int j=1;
if (Type=="string")
{
//===Repeater===
if (ctrl is Repeater)
{
for (int i=0;i<((Repeater)ctrl).Items.Count;i++)
{
CheckBox myCheckBox;
Label myLabel;
myCheckBox=(CheckBox)((Repeater)ctrl).Items[i].FindControl(cb_Id);
myLabel=(Label)((Repeater)ctrl).Items[i].FindControl(lbl_Id);
if(myCheckBox.Checked==true)
{
if (j==1)
{
str_Where=id+"='"+myLabel.Text+"'";
}
else
{
str_Where=str_Where+" or "+id+"='"+myLabel.Text+"'";
}
j=j+1;
}
}
}
//===DataList===
if (ctrl is DataList)
{
for (int i=0;i<((DataList)ctrl).Items.Count;i++)
{
CheckBox myCheckBox;
Label myLabel;
myCheckBox=(CheckBox)((DataList)ctrl).Items[i].FindControl(cb_Id);
myLabel=(Label)((DataList)ctrl).Items[i].FindControl(lbl_Id);
if(myCheckBox.Checked==true)
{
if (j==1)
{
str_Where=id+"='"+myLabel.Text+"'";
}
else
{
str_Where=str_Where+" or "+id+"='"+myLabel.Text+"'";
}
j=j+1;
}
}
}
//===DataGrid===
if (ctrl is DataGrid)
{
for (int i=0;i<((DataGrid)ctrl).Items.Count;i++)
{
CheckBox myCheckBox;
Label myLabel;
myCheckBox=(CheckBox)((DataGrid)ctrl).Items[i].FindControl(cb_Id);
myLabel=(Label)((DataGrid)ctrl).Items[i].FindControl(lbl_Id);
if(myCheckBox.Checked==true)
{
if (j==1)
{
str_Where=id+"='"+myLabel.Text+"'";
}
else
{
str_Where=str_Where+" or "+id+"='"+myLabel.Text+"'";
}
j=j+1;
}
}
}
}
if (Type=="int")
{
//===Repeater===
if (ctrl is Repeater)
{
for (int i=0;i<((Repeater)ctrl).Items.Count;i++)
{
CheckBox myCheckBox;
Label myLabel;
myCheckBox=(CheckBox)((Repeater)ctrl).Items[i].FindControl(cb_Id);
myLabel=(Label)((Repeater)ctrl).Items[i].FindControl(lbl_Id);
if(myCheckBox.Checked==true)
{
if (j==1)
{
str_Where=id+"="+myLabel.Text;
}
else
{
str_Where=str_Where+" or "+id+"="+myLabel.Text;
}
j=j+1;
}
}
}
//===DataList===
if (ctrl is DataList)
{
for (int i=0;i<((DataList)ctrl).Items.Count;i++)
{
CheckBox myCheckBox;
Label myLabel;
myCheckBox=(CheckBox)((DataList)ctrl).Items[i].FindControl(cb_Id);
myLabel=(Label)((DataList)ctrl).Items[i].FindControl(lbl_Id);
if(myCheckBox.Checked==true)
{
if (j==1)
{
str_Where=id+"="+myLabel.Text;
}
else
{
str_Where=str_Where+" or "+id+"="+myLabel.Text;
}
j=j+1;
}
}
}
//===DataGrid===
if (ctrl is DataGrid)
{
for (int i=0;i<((DataGrid)ctrl).Items.Count;i++)
{
CheckBox myCheckBox;
Label myLabel;
myCheckBox=(CheckBox)((DataGrid)ctrl).Items[i].FindControl(cb_Id);
myLabel=(Label)((DataGrid)ctrl).Items[i].FindControl(lbl_Id);
if(myCheckBox.Checked==true)
{
if (j==1)
{
str_Where=id+"="+myLabel.Text;
}
else
{
str_Where=str_Where+" or "+id+"="+myLabel.Text;
}
j=j+1;
}
}
}
}
return str_Where;
}
/// <summary>
/// 控件效果
/// </summary>
/// <param name="ctrls">控件数组,一种类型控件数组,目前只支持Button,TextBox两种类型控件,比如Control ctrls={btn_Add,Btn_Save}</param>
/// <param name="Type1">样式类型1,Button控件,支持鼠标滑过onmouseOver和鼠标滑开两种效果,TextBox控件,支持鼠标获得焦点onFocus和失去焦点两种效果</param>
/// <param name="Type2">样式类型2</param>
public void CtrlAttributes(Control [] ctrls,string Type1,string Type2)
{
for (int i=0;i<ctrls.Length;i++)
{
if (ctrls[i] is TextBox)
{
((TextBox)ctrls[i]).Attributes.Add("class",Type1);
((TextBox)ctrls[i]).Attributes.Add("onFocus","className='"+Type2+"'");
((TextBox)ctrls[i]).Attributes.Add("onBlur","className='"+Type1+"'");
}
if (ctrls[i] is WFNetCtrl.Calendar)
{
((WFNetCtrl.Calendar)ctrls[i]).Attributes.Add("class",Type1);
((WFNetCtrl.Calendar)ctrls[i]).Attributes.Add("onFocus","className='"+Type2+"'");
((WFNetCtrl.Calendar)ctrls[i]).Attributes.Add("onBlur","className='"+Type1+"'");
}
if (ctrls[i] is Button)
{
((Button)ctrls[i]).Attributes.Add("class",Type1);
((Button)ctrls[i]).Attributes.Add("onmouseOver","className='"+Type2+"'");
((Button)ctrls[i]).Attributes.Add("onmouseOut","className='"+Type1+"'");
}
}
}
/// <summary>
/// 获得CheckBoxLis,RadioButtonList,ListBox控件所有选中值并以逗号格开,形式:"2,3,4"
/// </summary>
/// <param name="listctrl">CheckBoxLis,RadioButtonList,ListBox控件</param>
/// <param name="type">类型,是想获得Value还是Text值</param>
/// <returns></returns>
public string GetCtrlSelValue(Control listctrl,string type)
{
string str_Value="";
switch (type)
{
//===要选择的是value===
case "value":
{
//===CheckBoxList===
if (listctrl is CheckBoxList)
{
for (int i=0;i<((CheckBoxList)listctrl).Items.Count;i++)
{
if (((CheckBoxList)listctrl).Items[i].Selected==true)
{
str_Value=str_Value+((CheckBoxList)listctrl).Items[i].Value+",";
}
}
if (str_Value!="")
{
str_Value=str_Value.Substring(0,str_Value.Length-1);
}
}
//===RadioButtonList===
if (listctrl is RadioButtonList)
{
for (int i=0;i<((RadioButtonList)listctrl).Items.Count;i++)
{
if (((RadioButtonList)listctrl).Items[i].Selected==true)
{
str_Value=((RadioButtonList)listctrl).Items[i].Value;
}
}
}
//===ListBox===
if (listctrl is ListBox)
{
for (int i=0;i<((ListBox)listctrl).Items.Count;i++)
{
if (((ListBox)listctrl).Items[i].Selected==true)
{
str_Value=str_Value+((ListBox)listctrl).Items[i].Value+",";
}
}
if (str_Value!="")
{
str_Value=str_Value.Substring(0,str_Value.Length-1);
}
}
break;
}
//===要选择的是Text===
case "text":
{
//===CheckBoxList===
if (listctrl is CheckBoxList)
{
for (int i=0;i<((CheckBoxList)listctrl).Items.Count;i++)
{
if (((CheckBoxList)listctrl).Items[i].Selected==true)
{
str_Value=str_Value+((CheckBoxList)listctrl).Items[i].Text+",";
}
}
if (str_Value!="")
{
str_Value=str_Value.Substring(0,str_Value.Length-1);
}
}
//===RadioButtonList===
if (listctrl is RadioButtonList)
{
for (int i=0;i<((RadioButtonList)listctrl).Items.Count;i++)
{
if (((RadioButtonList)listctrl).Items[i].Selected==true)
{
str_Value=((RadioButtonList)listctrl).Items[i].Text;
}
}
}
//===ListBox===
if (listctrl is ListBox)
{
for (int i=0;i<((ListBox)listctrl).Items.Count;i++)
{
if (((ListBox)listctrl).Items[i].Selected==true)
{
str_Value=str_Value+((ListBox)listctrl).Items[i].Text+",";
}
}
if (str_Value!="")
{
str_Value=str_Value.Substring(0,str_Value.Length-1);
}
}
break;
}
}
return str_Value;
}
//**********************************>> 上传文件 <<**********************************//
public string UpFile(string path,HtmlInputFile fl_Name,Page page)
{
if (fl_Name.PostedFile.ToString()=="")
{
Alert("请先选择一个文件再上传!",page);
throw(new Exception());
}
if(fl_Name.PostedFile.ContentLength>4000000)
{
Alert("文件大小限定在4MB以内!",page);
throw(new Exception());
}
if(File.Exists(Server.MapPath(path+Path.GetFileName(fl_Name.PostedFile.FileName))))
{
Alert("该文件已经存在,请改名再上传!",page);
throw(new Exception());
}
string strFullPath=Server.MapPath(path+Path.GetFileName(fl_Name.PostedFile.FileName));
fl_Name.PostedFile.SaveAs(strFullPath);
return Path.GetFileName(fl_Name.PostedFile.FileName);
}
public string UpFileType(string filetype,string path,HtmlInputFile fl_Name,Page page)
{
if (fl_Name.PostedFile.ToString()=="")
{
Alert("请先选择一个文件再上传!",page);
throw(new Exception());
}
if(fl_Name.PostedFile.ContentLength>4000000)
{
Alert("文件大小限定在4MB以内!",page);
throw(new Exception());
}
if(File.Exists(Server.MapPath(path+Path.GetFileName(fl_Name.PostedFile.FileName))))
{
Alert("该文件已经存在,请改名再上传!",page);
throw(new Exception());
}
string strFullPath=Server.MapPath(path+Path.GetFileName(fl_Name.PostedFile.FileName));
fl_Name.PostedFile.SaveAs(strFullPath);
return Path.GetFileName(fl_Name.PostedFile.FileName);
}
//**********************************>> 其他篇 <<**********************************//
/// <summary>
/// 服务器端弹出alert对话框
/// </summary>
/// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>
/// <param name="page">Page类</param>
public void Alert(string str_Message,Page page)
{
page.RegisterStartupScript("","<script>alert('"+str_Message+"');</script>");
}
/// <summary>
/// 服务器端弹出alert对话框
/// </summary>
/// <param name="str_Ctl_Name">获得焦点控件Id值,比如:txt_Name</param>
/// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>
/// <param name="page">Page类</param>
public void Alert(string str_Ctl_Name,string str_Message,Page page)
{
page.RegisterStartupScript("","<script>alert('"+str_Message+"');document.forms(0)."+str_Ctl_Name+".focus(); document.forms(0)."+str_Ctl_Name+".select();</script>");
}
/// <summary>
/// 服务器端弹出confirm对话框,询问用户准备转向相应操作,包括“确定”和“取消”时的操作
/// </summary>
/// <param name="str_Message">提示信息,比如:"成功增加数据,单击/"确定/"按钮填写流程,单击/"取消/"修改数据"</param>
/// <param name="btn_Redirect_Flow">"确定"按钮id值</param>
/// <param name="btn_Redirect_Self">"取消"按钮id值</param>
/// <param name="page">Page类</param>
public void Confirm(string str_Message,string btn_Redirect_Flow,string btn_Redirect_Self,Page page)
{
page.RegisterStartupScript("","<script> if (confirm('"+str_Message+"')==true){document.forms(0)."+btn_Redirect_Flow+".click();}else{document.forms(0)."+btn_Redirect_Self+".click();}</script>");
}
/// <summary>
/// 刷新某个桢
/// </summary>
/// <param name="Frame">桢名称</param>
/// <param name="url">连接</param>
/// <param name="page">page对象</param>
public void ReloadFrame(string Frame,string url,Page page)
{
page.RegisterStartupScript("","<script language=/"javascript/">parent.frames('"+Frame+"').document.location.href='"+url+"';</script>");
}
/// <summary>
/// 获得某个字符串在另个字符串最后一次出现时后面所有字符
/// </summary>
/// <param name="strOriginal">要处理字符</param>
/// <param name="strSymbol">符号</param>
/// <returns>返回值</returns>
public string GetLastStr(string strOriginal,string strSymbol)
{
int strPlace=strOriginal.LastIndexOf(strSymbol)+strSymbol.Length;
strOriginal=strOriginal.Substring(strPlace);
return strOriginal;
}
/// <summary>
/// 获得某个字符串在另个字符串第一次出现时前面所有字符
/// </summary>
/// <param name="strOriginal">要处理字符</param>
/// <param name="strSymbol">符号</param>
/// <returns>返回值</returns>
public string GetFirstStr(string strOriginal,string strSymbol)
{
int strPlace=strOriginal.IndexOf(strSymbol);
if (strPlace!=-1)
strOriginal=strOriginal.Substring(0,strPlace);
return strOriginal;
}
/// <summary>
/// 截取字符串
/// </summary>
/// <param name="Str">要处理字符串</param>
/// <param name="StrLen">截取长度</param>
/// <returns></returns>
public string CutStr(string Str, int StrLen)
{
if (Str != null && Convert.IsDBNull(StrLen) == false)
{
int t = 0;
for (int i = 0; i <= StrLen; i++)
{
if (t >= StrLen)
{
Str = Str.Substring(0,i) + "…";
break;
}
else
{
if (i >= Str.Length)
{
Str = Str.Substring(0,i);
break;
}
}
int c = Math.Abs((int)Str[i]);
if (c > 255)
{
t += 2;
}
else
{
t++;
}
}
}
else
{
Str = null;
}
return Str;
}
/// <summary>
/// 获得14位时间字符+。。。位的时间随机数
/// </summary>
/// <returns></returns>
public string GetId()
{
return GetDateRandom(6);
}
public string GetDateRandom(int int_Count)
{
string strData=DateTime.Now.ToString("yyyyMMddhhmmss");
strData=strData.Replace(":","");
strData=strData.Replace("-","");
strData=strData.Replace(" ","");
strData=strData+GetRandom(int_Count);
return strData;
}
public string GetRandom(int int_Count)
{
string str_RV="1";
for (int i=0;i<int_Count-2;i++)
{
str_RV=str_RV+"0";
}
Random r=new Random();
str_RV=r.Next(int.Parse(str_RV)).ToString();
int int_Count1=int_Count-str_RV.Length;
if (int_Count1>0)
{
for (int i=0;i<int_Count1;i++)
{
str_RV=str_RV+"0";
}
}
return str_RV;
}
public string GetHtmlFormat(string strContent)
{
string val=strContent;
if(val==null)
{
val="";
}
//val=val.Replace("/r","<br>");
val=val.Replace("/n","<br>");
val=val.Replace(" "," ");
return val;
}
/// <summary>
/// 获得某个字符串在另个字符串第一次出现时前面所有字符
/// </summary>
/// <param name="strOriginal">要处理字符</param>
/// <param name="strSymbol">符号</param>
/// <returns>返回值</returns>
public string GetSecondStr(string strOriginal,string strSymbol)
{
string[] arr=strOriginal.Split('_');
strOriginal=arr[1];
return strOriginal;
}
public int GetStrAppearTime(string strOriginal,string strSymbol)
{
return strOriginal.Length-strOriginal.Replace(strSymbol,"").Length;
}
/// <summary>
/// 获得拼音
/// </summary>
/// <param name="str_Spell">汉字</param>
/// <returns></returns>
public string GetSpell(string str_Spell)
{
try
{
Hashtable t=hb();
byte[] b=System.Text.Encoding.Default.GetBytes(str_Spell);
int p;
StringBuilder ret=new StringBuilder();
for(int i=0;i< b.Length;i++)
{
p=(int)b[i];
if(p>160)
{
p=p*256+b[++i]-65536;
ret.Append(g(t,p));
}
else
{
ret.Append((char)p);
}
}
t.Clear();
return ret.ToString();
}
catch
{
return "";
}
}
private string g(Hashtable ht,int num)
{
if(num < -20319||num > -10247)
return "";
while(!ht.ContainsKey(num))
num--;
return ht[num].ToString();
}
private Hashtable hb()
{
Hashtable ht=new Hashtable();
ht.Add(-20319,"a");
ht.Add(-20317,"ai");ht.Add(-20304,"an"); ht.Add(-20295,"ang");
ht.Add(-20292,"ao");ht.Add(-20283,"ba"); ht.Add(-20265,"bai");
ht.Add(-20257,"ban");ht.Add(-20242,"bang"); ht.Add(-20230,"bao");
ht.Add(-20051,"bei"); ht.Add(-20036,"ben"); ht.Add(-20032,"beng");
ht.Add(-20026,"bi"); ht.Add(-20002,"bian"); ht.Add(-19990,"biao");
ht.Add(-19986,"bie"); ht.Add(-19982,"bin"); ht.Add(-19976,"bing");
ht.Add(-19805,"bo"); ht.Add(-19784,"bu"); ht.Add(-19775,"ca");
ht.Add(-19774,"cai"); ht.Add(-19763,"can"); ht.Add(-19756,"cang");
ht.Add(-19751,"cao"); ht.Add(-19746,"ce"); ht.Add(-19741,"ceng");
ht.Add(-19739,"cha"); ht.Add(-19728,"chai"); ht.Add(-19725,"chan");
ht.Add(-19715,"chang"); ht.Add(-19540,"chao"); ht.Add(-19531,"che");
ht.Add(-19525,"chen"); ht.Add(-19515,"cheng"); ht.Add(-19500,"chi");
ht.Add(-19484,"chong"); ht.Add(-19479,"chou"); ht.Add(-19467,"chu");
ht.Add(-19289,"chuai"); ht.Add(-19288,"chuan"); ht.Add(-19281,"chuang");
ht.Add(-19275,"chui"); ht.Add(-19270,"chun"); ht.Add(-19263,"chuo");
ht.Add(-19261,"ci"); ht.Add(-19249,"cong"); ht.Add(-19243,"cou");
ht.Add(-19242,"cu"); ht.Add(-19238,"cuan"); ht.Add(-19235,"cui");
ht.Add(-19227,"cun"); ht.Add(-19224,"cuo"); ht.Add(-19218,"da");
ht.Add(-19212,"dai"); ht.Add(-19038,"dan"); ht.Add(-19023,"dang");
ht.Add(-19018,"dao"); ht.Add(-19006,"de"); ht.Add(-19003,"deng");
ht.Add(-18996,"di"); ht.Add(-18977,"dian"); ht.Add(-18961,"diao");
ht.Add(-18952,"die"); ht.Add(-18783,"ding"); ht.Add(-18774,"diu");
ht.Add(-18773,"dong"); ht.Add(-18763,"dou"); ht.Add(-18756,"du");
ht.Add(-18741,"duan"); ht.Add(-18735,"dui"); ht.Add(-18731,"dun");
ht.Add(-18722,"duo"); ht.Add(-18710,"e"); ht.Add(-18697,"en");
ht.Add(-18696,"er"); ht.Add(-18526,"fa"); ht.Add(-18518,"fan");
ht.Add(-18501,"fang"); ht.Add(-18490,"fei"); ht.Add(-18478,"fen");
ht.Add(-18463,"feng"); ht.Add(-18448,"fo"); ht.Add(-18447,"fou");
ht.Add(-18446,"fu"); ht.Add(-18239,"ga"); ht.Add(-18237,"gai");
ht.Add(-18231,"gan"); ht.Add(-18220,"gang"); ht.Add(-18211,"gao");
ht.Add(-18201,"ge"); ht.Add(-18184,"gei"); ht.Add(-18183,"gen");
ht.Add(-18181,"geng"); ht.Add(-18012,"gong"); ht.Add(-17997,"gou");
ht.Add(-17988,"gu"); ht.Add(-17970,"gua"); ht.Add(-17964,"guai");
ht.Add(-17961,"guan"); ht.Add(-17950,"guang"); ht.Add(-17947,"gui");
ht.Add(-17931,"gun"); ht.Add(-17928,"guo"); ht.Add(-17922,"ha");
ht.Add(-17759,"hai"); ht.Add(-17752,"han"); ht.Add(-17733,"hang");
ht.Add(-17730,"hao"); ht.Add(-17721,"he"); ht.Add(-17703,"hei");
ht.Add(-17701,"hen"); ht.Add(-17697,"heng"); ht.Add(-17692,"hong");
ht.Add(-17683,"hou"); ht.Add(-17676,"hu"); ht.Add(-17496,"hua");
ht.Add(-17487,"huai"); ht.Add(-17482,"huan"); ht.Add(-17468,"huang");
ht.Add(-17454,"hui"); ht.Add(-17433,"hun"); ht.Add(-17427,"huo");
ht.Add(-17417,"ji"); ht.Add(-17202,"jia"); ht.Add(-17185,"jian");
ht.Add(-16983,"jiang"); ht.Add(-16970,"jiao"); ht.Add(-16942,"jie");
ht.Add(-16915,"jin"); ht.Add(-16733,"jing"); ht.Add(-16708,"jiong");
ht.Add(-16706,"jiu"); ht.Add(-16689,"ju"); ht.Add(-16664,"juan");
ht.Add(-16657,"jue"); ht.Add(-16647,"jun"); ht.Add(-16474,"ka");
ht.Add(-16470,"kai"); ht.Add(-16465,"kan"); ht.Add(-16459,"kang");
ht.Add(-16452,"kao"); ht.Add(-16448,"ke"); ht.Add(-16433,"ken");
ht.Add(-16429,"keng"); ht.Add(-16427,"kong"); ht.Add(-16423,"kou");
ht.Add(-16419,"ku"); ht.Add(-16412,"kua"); ht.Add(-16407,"kuai");
ht.Add(-16403,"kuan"); ht.Add(-16401,"kuang"); ht.Add(-16393,"kui");
ht.Add(-16220,"kun"); ht.Add(-16216,"kuo"); ht.Add(-16212,"la");
ht.Add(-16205,"lai"); ht.Add(-16202,"lan"); ht.Add(-16187,"lang");
ht.Add(-16180,"lao"); ht.Add(-16171,"le"); ht.Add(-16169,"lei");
ht.Add(-16158,"leng"); ht.Add(-16155,"li"); ht.Add(-15959,"lia");
ht.Add(-15958,"lian"); ht.Add(-15944,"liang"); ht.Add(-15933,"liao");
ht.Add(-15920,"lie"); ht.Add(-15915,"lin"); ht.Add(-15903,"ling");
ht.Add(-15889,"liu"); ht.Add(-15878,"long"); ht.Add(-15707,"lou");
ht.Add(-15701,"lu");ht.Add(-15681,"lv");ht.Add(-15667,"luan");
ht.Add(-15661,"lue");ht.Add(-15659,"lun");ht.Add(-15652,"luo");
ht.Add(-15640,"ma");ht.Add(-15631,"mai");ht.Add(-15625,"man");
ht.Add(-15454,"mang");ht.Add(-15448,"mao");ht.Add(-15436,"me");
ht.Add(-15435,"mei");ht.Add(-15419,"men");ht.Add(-15416,"meng");
ht.Add(-15408,"mi");ht.Add(-15394,"mian");ht.Add(-15385,"miao");
ht.Add(-15377,"mie");ht.Add(-15375,"min");ht.Add(-15369,"ming");
ht.Add(-15363,"miu");ht.Add(-15362,"mo");ht.Add(-15183,"mou");
ht.Add(-15180,"mu");ht.Add(-15165,"na");ht.Add(-15158,"nai");
ht.Add(-15153,"nan");ht.Add(-15150,"nang");ht.Add(-15149,"nao");
ht.Add(-15144,"ne");ht.Add(-15143,"nei");ht.Add(-15141,"nen");
ht.Add(-15140,"neng");ht.Add(-15139,"ni");ht.Add(-15128,"nian");
ht.Add(-15121,"niang");ht.Add(-15119,"niao");ht.Add(-15117,"nie");
ht.Add(-15110,"nin");ht.Add(-15109,"ning");ht.Add(-14941,"niu");
ht.Add(-14937,"nong");ht.Add(-14933,"nu");ht.Add(-14930,"nv");
ht.Add(-14929,"nuan");ht.Add(-14928,"nue");ht.Add(-14926,"nuo");
ht.Add(-14922,"o");ht.Add(-14921,"ou");ht.Add(-14914,"pa");
ht.Add(-14908,"pai");ht.Add(-14902,"pan");ht.Add(-14894,"pang");
ht.Add(-14889,"pao");ht.Add(-14882,"pei");ht.Add(-14873,"pen");
ht.Add(-14871,"peng");ht.Add(-14857,"pi");ht.Add(-14678,"pian");
ht.Add(-14674,"piao");ht.Add(-14670,"pie");ht.Add(-14668,"pin");
ht.Add(-14663,"ping");ht.Add(-14654,"po");ht.Add(-14645,"pu");
ht.Add(-14630,"qi");ht.Add(-14594,"qia");ht.Add(-14429,"qian");
ht.Add(-14407,"qiang");ht.Add(-14399,"qiao");ht.Add(-14384,"qie");
ht.Add(-14379,"qin");ht.Add(-14368,"qing");ht.Add(-14355,"qiong");
ht.Add(-14353,"qiu");ht.Add(-14345,"qu");ht.Add(-14170,"quan");
ht.Add(-14159,"que");ht.Add(-14151,"qun");ht.Add(-14149,"ran");
ht.Add(-14145,"rang");ht.Add(-14140,"rao");ht.Add(-14137,"re");
ht.Add(-14135,"ren");ht.Add(-14125,"reng");ht.Add(-14123,"ri");
ht.Add(-14122,"rong");ht.Add(-14112,"rou");ht.Add(-14109,"ru");
ht.Add(-14099,"ruan");ht.Add(-14097,"rui");ht.Add(-14094,"run");
ht.Add(-14092,"ruo");ht.Add(-14090,"sa");ht.Add(-14087,"sai");
ht.Add(-14083,"san");ht.Add(-13917,"sang");ht.Add(-13914,"sao");
ht.Add(-13910,"se");ht.Add(-13907,"sen");ht.Add(-13906,"seng");
ht.Add(-13905,"sha");ht.Add(-13896,"shai");ht.Add(-13894,"shan");
ht.Add(-13878,"shang");ht.Add(-13870,"shao");ht.Add(-13859,"she");
ht.Add(-13847,"shen");ht.Add(-13831,"sheng");ht.Add(-13658,"shi");
ht.Add(-13611,"shou");ht.Add(-13601,"shu");ht.Add(-13406,"shua");
ht.Add(-13404,"shuai");ht.Add(-13400,"shuan");ht.Add(-13398,"shuang");
ht.Add(-13395,"shui");ht.Add(-13391,"shun");ht.Add(-13387,"shuo");
ht.Add(-13383,"si");ht.Add(-13367,"song");ht.Add(-13359,"sou");
ht.Add(-13356,"su");ht.Add(-13343,"suan");ht.Add(-13340,"sui");
ht.Add(-13329,"sun");ht.Add(-13326,"suo");ht.Add(-13318,"ta");
ht.Add(-13147,"tai");ht.Add(-13138,"tan");ht.Add(-13120,"tang");
ht.Add(-13107,"tao");ht.Add(-13096,"te");ht.Add(-13095,"teng");
ht.Add(-13091,"ti");ht.Add(-13076,"tian");ht.Add(-13068,"tiao");
ht.Add(-13063,"tie");ht.Add(-13060,"ting");ht.Add(-12888,"tong");
ht.Add(-12875,"tou");ht.Add(-12871,"tu");ht.Add(-12860,"tuan");
ht.Add(-12858,"tui");ht.Add(-12852,"tun");ht.Add(-12849,"tuo");
ht.Add(-12838,"wa");ht.Add(-12831,"wai");ht.Add(-12829,"wan");
ht.Add(-12812,"wang");ht.Add(-12802,"wei");ht.Add(-12607,"wen");
ht.Add(-12597,"weng");ht.Add(-12594,"wo");ht.Add(-12585,"wu");
ht.Add(-12556,"xi");ht.Add(-12359,"xia");ht.Add(-12346,"xian");
ht.Add(-12320,"xiang");ht.Add(-12300,"xiao");ht.Add(-12120,"xie");
ht.Add(-12099,"xin");ht.Add(-12089,"xing");ht.Add(-12074,"xiong");
ht.Add(-12067,"xiu");ht.Add(-12058,"xu");ht.Add(-12039,"xuan");
ht.Add(-11867,"xue");ht.Add(-11861,"xun");ht.Add(-11847,"ya");
ht.Add(-11831,"yan");ht.Add(-11798,"yang");ht.Add(-11781,"yao");
ht.Add(-11604,"ye");ht.Add(-11589,"yi");ht.Add(-11536,"yin");
ht.Add(-11358,"ying");ht.Add(-11340,"yo");ht.Add(-11339,"yong");
ht.Add(-11324,"you");ht.Add(-11303,"yu");ht.Add(-11097,"yuan");
ht.Add(-11077,"yue");ht.Add(-11067,"yun");ht.Add(-11055,"za");
ht.Add(-11052,"zai");ht.Add(-11045,"zan");ht.Add(-11041,"zang");
ht.Add(-11038,"zao");ht.Add(-11024,"ze");ht.Add(-11020,"zei");
ht.Add(-11019,"zen");ht.Add(-11018,"zeng");ht.Add(-11014,"zha");
ht.Add(-10838,"zhai");ht.Add(-10832,"zhan");ht.Add(-10815,"zhang");
ht.Add(-10800,"zhao");ht.Add(-10790,"zhe");ht.Add(-10780,"zhen");
ht.Add(-10764,"zheng");ht.Add(-10587,"zhi");ht.Add(-10544,"zhong");
ht.Add(-10533,"zhou");ht.Add(-10519,"zhu");ht.Add(-10331,"zhua");
ht.Add(-10329,"zhuai");ht.Add(-10328,"zhuan");ht.Add(-10322,"zhuang");
ht.Add(-10315,"zhui");ht.Add(-10309,"zhun");ht.Add(-10307,"zhuo");
ht.Add(-10296,"zi");ht.Add(-10281,"zong");ht.Add(-10274,"zou");
ht.Add(-10270,"zu");ht.Add(-10262,"zuan");ht.Add(-10260,"zui");
ht.Add(-10256,"zun");ht.Add(-10254,"zuo");ht.Add(-10247,"zz");
return ht;
}