本文整理汇总了C#中DB类的典型用法代码示例。如果您正苦于以下问题:C# DB类的具体用法?C# DB怎么用?C# DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DB类属于命名空间,在下文中一共展示了DB类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SExecuteScalar
public static object SExecuteScalar(string sql, params object[] parameter)
{
using (DB db = new DB())
{
return db.ExecuteScalar(sql, parameter);
}
}
示例2: InsertDataBase
//在数据表Resources插入一条记录操作
protected bool InsertDataBase()
{
bool result = false;
using (SqlConnection conn = new DB().GetConnection())
{
//向resources插入一条记录操作
StringBuilder sb = new StringBuilder("Insert into Resources (ResourceName,FileName,FilePath,FileSizeInKB,FileType,Extentsion,FolderID,FolderName,UserID,CDT,Status,UserName)");
sb.Append(" values(@ResourceName,@FileName,@FilePath,@FileSize,@FileType,@Extentsion,@FolderID,@FolderName,@UserID,@CDT,@Status,@UserName)");
SqlCommand cmd = new SqlCommand(sb.ToString(), conn);
//cmd.Parameters.AddWithValue("@ResourceName", TextBox1.Text);
cmd.Parameters.AddWithValue("@ResourceName", TextBox1.Text.Trim());
cmd.Parameters.AddWithValue("@FileName", FN.Text);
cmd.Parameters.AddWithValue("@FilePath", FP.Text);
cmd.Parameters.AddWithValue("@FileSize", FS.Text);
cmd.Parameters.AddWithValue("@FileType", ResourceTypeLabel.Text);
cmd.Parameters.AddWithValue("@Extentsion", FET.Text);
cmd.Parameters.AddWithValue("@FolderID", 0);
cmd.Parameters.AddWithValue("@FolderName", "");
cmd.Parameters.AddWithValue("@UserID", Session["UserID"].ToString());
cmd.Parameters.AddWithValue("@UserName", Session["UserName"].ToString());
cmd.Parameters.AddWithValue("@CDT", DateTime.Now);
cmd.Parameters.AddWithValue("@Status", 0);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
//插入成功
result = true;
}
return result;
}
示例3: Save
public bool Save(DB.Stru.事务科.专项救助_低保边缘户 stru)
{
string strID = Orm.Save(stru);
stru.ID = strID;
return ! String.IsNullOrEmpty(strID);
}
示例4: Save
public bool Save(DB.Stru.福利中心.老人费用退费管理 stru)
{
string strID = Orm.Save(stru);
stru.ID = strID;
return ! String.IsNullOrEmpty(strID);
}
示例5: getWorkInfo
/**
* Fetches info needed from the database.
*/
private RevisionWorkInfo getWorkInfo(DB db, int revisionWorkID, int workID) {
using (var cmd = db.CreateCommand ()) {
cmd.CommandText = @"
SELECT revision.revision, lane.id, lane.repository, lane.lane
FROM revisionwork
INNER JOIN revision ON revision.id = revisionwork.revision_id
INNER JOIN lane ON lane.id = revision.lane_id
WHERE revisionwork.id = @rwID;
SELECT command.command
FROM work
INNER JOIN command ON command.id = work.command_id
WHERE work.id = @wID
";
DB.CreateParameter (cmd, "rwID", revisionWorkID);
DB.CreateParameter (cmd, "wID", workID);
using (var reader = cmd.ExecuteReader ()) {
RevisionWorkInfo info;
reader.Read ();
info.hash = reader.GetString (0);
info.laneID = reader.GetInt32 (1);
info.repoURL = reader.GetString (2);
info.laneName = reader.GetString (3);
reader.NextResult ();
reader.Read ();
info.command = reader.GetString (0);
return info;
}
}
}
示例6: confirm_Click
protected void confirm_Click(object sender, EventArgs e)///首先判断该人员是否已经安排过值班
{
DB db = new DB();
string str = "SELECT jobskyerID FROM dutyTimeTable";
string jobskyerID = chooseName.SelectedValue;
SqlConnection con = new SqlConnection();
con = db.GetCon();
SqlCommand com = new SqlCommand(str, con);
SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds = new DataSet();
da.Fill(ds);
///SqlDataReader dr = com.ExecuteReader();
int k = ds.Tables[0].Rows.Count;
for (int i = 0; i < k; ++i)
{
if (jobskyerID == ds.Tables[0].Rows[i]["jobskyerID"].ToString())
{
Update_DutyTime();
}
if (i == k)
{
Insert_DutyTime();
}
}
}
示例7: Update_DutyTime
public bool Update_DutyTime()///如果选择了安排过值班的人,就更新值班安排数据
{
DB db = new DB();
string dutyInTime = chooseWeekday.SelectedValue + chooseSignInTime.SelectedValue;
string dutyOutTime = chooseWeekday.SelectedValue + chooseSignOutTime.SelectedValue;
string str = "UPDATE dutyTimeTable SET [email protected],[email protected] WHERE [email protected]";
SqlConnection con = new SqlConnection();
con = db.GetCon();
SqlCommand com = new SqlCommand(str, con);
com.Parameters.Add("@dutyInTime", SqlDbType.DateTime, 0).Value = dutyInTime;
com.Parameters.Add("@dutyOutTime", SqlDbType.DateTime, 0).Value = dutyOutTime;
com.Parameters.Add("@jobskyerID", SqlDbType.DateTime, 0).Value = chooseName.SelectedValue;
try
{
com.ExecuteNonQuery();
Sign_Result.Text = "更新值班成功!";
}
catch (Exception ex)
{
Sign_Result.Text = "更新值班失败!";
return false;
}
finally
{
com.Dispose();
con.Close();
}
return true;
}
示例8: GetJobName
public string GetJobName(object jobskyerID) //把jobskyerID转化为jobName输出
{
DB db = new DB();
SqlDataReader dr = db.reDr("SELECT jobName FROM jobskyer WHERE jobskyerID='" + jobskyerID + "'");
dr.Read();
return dr.GetValue(0).ToString();
}
示例9: SetData
public void SetData( DB.Stru.优抚科.优抚对象.伤残人员.基本信息 stru )
{
txt行政区划.Text = stru.行政区划;
txt身份证号码.Text = stru.身份证号码 ;
dat出生日期.strDate = stru.出生日期 ;
cmb伤残等级.Text = stru.伤残等级 ;
cmb伤残属别.Text = stru.伤残属别 ;
dat参加工作时间.Text = stru.入伍时间 ;
cmb劳动能力.Text = stru.劳动能力 ;
cmb就业情况.Text = stru.就业情况 ;
cmb户口簿住址类别.Text = stru.户口簿住址类别 ;
txt姓名.Text = stru.姓名;
cmb民族.Text = stru.民族;
cmb性别.Text = stru.性别 ;
cmb伤残性质.Text = stru.伤残性质;
cmb婚姻状况.Text = stru.婚姻状况;
dat退伍时间.strDate = stru.退伍时间 ;
cmb生活能力.Text = stru.生活能力 ;
cmb户口类别.Text = stru.户口类别 ;
txt联系电话.Text = stru.联系电话 ;
txt工作单位.Text = stru.工作单位 ;
txt户口簿地址.Text = stru.户口簿住址 ;
txt实际居住地地址.Text = stru.实际居住地址 ;
txt备注.Text = stru.备注 ;
}
示例10: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
int i = 0;
using (SqlConnection conn = new DB().GetConnection())
{
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "Delete from SubMenu where ID in (" + IDSLabel.Text + ") ";
conn.Open();
i = cmd.ExecuteNonQuery();
cmd.Dispose();
cmd.CommandText = "select * from SubMenu where ID in (" + IDSLabel.Text + ") order by ID desc";
SqlDataReader rd = cmd.ExecuteReader();
GridView1.DataSource = rd;
GridView1.DataBind();
rd.Close();
conn.Close();
}
if (i > 0)
{
ResultLabel.Text = "成功删除!";
ResultLabel.ForeColor = System.Drawing.Color.Green;
}
else
{
ResultLabel.Text = "操作失败,请重试!";
ResultLabel.ForeColor = System.Drawing.Color.Red;
}
}
示例11: Add_Update
private bool Add_Update()
{
try
{
DB DataBase = new DB("Categories");
DataBase.AddColumn("cat_name", Category_TB.Text.Trim());
if(Category_Id == null)
{
if(DataBase.IsNotExist("cat_id", "cat_name"))
{
return Confirm.Check(DataBase.Insert());
}
else
{
Message.Show("لقد تم تسجيل هذه الفئة من قبل", MessageBoxButton.OK, 5);
return false;
}
}
else
{
DataBase.AddCondition("cat_id", this.Category_Id);
return Confirm.Check(DataBase.Update());
}
}
catch
{
//MessageBox.Show("kiki_method");
return false;
}
}
示例12: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int RoleID = Convert.ToInt16(Session["RoleID"].ToString());
if (Session["RoleID"] == null || Session["UserID"] == null)
{
Util.ShowMessage("用户登录超时,请重新登录!", "Login2.aspx");
}
else if (RoleID > 1)
{
Util.ShowMessage("您没有访问该页面的权限!", "Login2.aspx");
}
else
{
UserName.Focus();
using (SqlConnection conn = new DB().GetConnection())
{
string sql1 = "select * from Roles order by ID asc";
SqlCommand cmd1 = new SqlCommand(sql1, conn);
conn.Open();
SqlDataReader rd1 = cmd1.ExecuteReader();
Role.DataSource = rd1;
Role.DataTextField = "RoleName";
Role.DataValueField = "ID";
Role.DataBind();
rd1.Close();
}
}
}
}
示例13: clearLine
protected string clearLine()
{
bool result = false;
string line = Request.Form["line"];
if (!string.IsNullOrEmpty(line) && line != "all")
{
using (DB db = new DB())
{
List<DowntimeData> list = (from o in db.DowntimeDataSet
where o.Client == "admin"
&& o.Line == line
select o).ToList();
if (list.Count() > 0)
{
foreach (DowntimeData dt in list)
{
db.DeleteObject(dt);
}
}
result = db.SaveChanges() > 0;
}
}
return result.ToString();
}
示例14: SInsert
public static int SInsert(string sql, params object[] parameter)
{
using (DB db = new DB())
{
return db.Insert(sql, parameter);
}
}
示例15: ScoreRankList_Bind
public bool ScoreRankList_Bind()///下拉列表绑定数据
{
DB db = new DB();
string sql_game = "SELECT * FROM GAME ";
SqlConnection con = new SqlConnection();
con = db.GetCon();
con.Open();
SqlCommand cmd = new SqlCommand(sql_game, con);
SqlDataReader sqlRead_Game = cmd.ExecuteReader();
try
{
ScoreRankList.DataSource = sqlRead_Game;
ScoreRankList.DataTextField = "gamName";
ScoreRankList.DataValueField = "gameID";
ScoreRankList.DataBind();
ScoreRankList.Items.Add(new ListItem("请选择","-1"));
ScoreRankList.SelectedValue = "-1";
}
catch (Exception ex)
{
return false;
}
finally
{
cmd.Dispose();
con.Close();
}
return true;
}