- 博客(1)
- 资源 (5)
- 收藏
- 关注
原创 字符超过某一指定长度自动换行
function cutStrLine(str,len){var fuck='';var myArray = str.split("");for(var i=0;i{ if(i%len==0&&i!=0) { fuck+="\n"; fuck+=myArray[i]; } else{ fuck+=myArray[i]; } } re
2013-11-28 21:46:54
1511
学生管理系统--C#
C#学生管理系统
主要代码:
(1)自定义函数类代码:
public class LinkDataBase
{
private string strSQL;
//与SQL Server 的连接字符串设置
//与数据库的连接
private string connectionString = "server = .;database=stu_Manage;uid=sa;pwd=123";
private static SqlConnection con = new SqlConnection("server = .;database=stu_Manage;uid=sa;pwd=123");
private SqlConnection myConnection;
private DataSet ds = new DataSet();
private SqlDataAdapter da;
public DataSet SelectDataBase(string tempStrSQL, string tempTableName) //根据输入的SQL语句检索数据库数据
{
this.strSQL = tempStrSQL;
this.myConnection = new SqlConnection(connectionString);
this.da = new SqlDataAdapter(this.strSQL, this.myConnection);
this.ds.Clear();
this.da.Fill(ds, tempTableName);
//返回填充了数据的DataSet,其中数据表以tempTableName给出的字符串命名
return ds;
}
public DataTable SelectDataBase(string tempStrSQL) //检索数据库数据(传字符串直接操作数据库)
{
this.myConnection = new
SqlConnection(connectionString);
DataSet tempDataSet = new DataSet();
this.da = new SqlDataAdapter
(tempStrSQL, this.myConnection);
this.da.Fill(tempDataSet);
return tempDataSet.Tables[0];
}
public void deleteInfo(string strcmd)//删除信息
{
SqlCommand cmd = new SqlCommand(strcmd, con);
try
{
con.Open();
if (MessageBox.Show("确定要删除吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
cmd.ExecuteNonQuery();
MessageBox.Show("删除成功!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
finally
{ con.Close(); }
}
public void addInfo(string strcmd)//定义添加信息事件
{
try
{
con.Open();
SqlCommand cmd = new SqlCommand(strcmd, con);
cmd.ExecuteNonQuery();
MessageBox.Show("添加成功");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
finally
{ con.Close(); }
}
public void updateInfo(string strcmd)//自定义更新信息方法
{
try
{
con.Open();
SqlCommand cmd = new SqlCommand(strcmd, con);
cmd.ExecuteNonQuery();
MessageBox.Show("修改成功");
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
finally
{ con.Close(); }
}
}
.
.
.
.
.
.
.
.
.
(2)
>
.
.
.
2011-07-02
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人