首页
新闻
博问
会员
知识库
专题
.NET技术
Web前端
软件设计
手机开发
软件工程
程序人生
项目管理
数据库
最新文章
您的位置:
知识库
»
程序人生
回忆孔先生
作者:
梁逸晨
来源:
博客园
发布时间: 2008-12-25 23:34 阅读: 1486 次 推荐: 0
原文链接
[收藏]
摘要:
由鲁迅笔下的孔乙己这一人物展开的对程序员的描绘
[1]
1.人物刻画
[2] 2.敲击代码
[3]
3.结尾
using
System;
using
System.Data;
using
System.Data.Common;
namespace
kongyiji
{
interface
IHui
{
void
Print();
void
Print(
int
step);
}
/**/
///
///
抽象基类,实现通用的草字头输出
///
abstract
class
AHui: IHui
{
IHui i;
private
IDbCommand comm;
private
IDbConnection conn;
private
DbProviderFactory _dbFac;
private
IDbDataParameter pram;
public
AHui(DbProviderFactory DbFac)
{
Console.WriteLine(
"
艹
"
);
_dbFac
=
DbFac;
}
public
abstract
void
Print();
protected
void
SaveSwitch(
string
hui_type)
{
conn
=
_dbFac.CreateConnection();
conn.ConnectionString
=
@"
Data Source=localhost;Initial Catalog=local_db;Persist Security Info=True;User ID=sa;Password=123456789
"
;
comm
=
conn.CreateCommand();
comm.CommandText
=
"
INSERT INTO LOG(hui_type) VALUES(@hui_type);
"
;
pram
=
comm.CreateParameter();
pram.DbType
=
DbType.String;
pram.ParameterName
=
"
@hui_type
"
;
pram.Value
=
hui_type;
//
conn.Open();
//
comm.ExecuteNonQuery();
//
conn.Close();
}
public
void
Print(
int
step)
{
i
=
HuiFactory.Hui(_dbFac,step);
i.Print();
}
}
/**/
///
///
回字写法
///
class
SelectHui: AHui
{
string
_hui;
public
SelectHui(
string
select_hui, DbProviderFactory DbFac)
:
base
(DbFac)
{
_hui
=
select_hui;
}
public
override
void
Print()
{
Console.WriteLine(_hui);
SaveSwitch(_hui);
}
}
class
HuiFactory
{
public
static
IHui Hui(DbProviderFactory DbFac,
int
step)
{
IHui temp
=
null
;
switch
(step)
{
case
1
:
temp
=
new
SelectHui(
"
回
"
, DbFac);
break
;
case
2
:
temp
=
new
SelectHui(
"
囘
"
, DbFac);
break
;
case
3
:
temp
=
new
SelectHui(
"
囬
"
, DbFac);
break
;
case
4
:
temp
=
new
SelectHui(
"
廻
"
, DbFac);
break
;
default
:
temp
=
new
SelectHui(
"
廻
"
, DbFac);
break
;
}
return
temp;
}
}
class
Program
{
static
void
Main(
string
[] args)
{
DbProviderFactory fac
=
DbProviderFactories.GetFactory(
"
System.Data.SqlClient
"
);
IHui i
=
HuiFactory.Hui(fac,
4
);
i.Print();
i.Print(
2
);
}
}
}
后退<<上一页
继续>>下一页
[第1页]
[第2页]
[第3页]
0
0
请先
登录
提交中...
标签:
人生经验
推荐链接
程序员问答平台,解决您的技术难题
程序人生热门文章
程序人生最新文章
最新新闻
热门新闻