当前位置: 首页>>代码示例>>C#>>正文


C# DB类代码示例

本文整理汇总了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);
     }
 }
开发者ID:nokitty,项目名称:chaxin,代码行数:7,代码来源:DB.cs

示例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;
    }
开发者ID:ZRUIK,项目名称:SETC,代码行数:32,代码来源:File_Browse.aspx.cs

示例3: Save

        public bool Save(DB.Stru.事务科.专项救助_低保边缘户 stru)
        {
            string strID =  Orm.Save(stru);
            stru.ID = strID;

            return ! String.IsNullOrEmpty(strID);
        }
开发者ID:cheng521yun,项目名称:https---github.com-frontflag-FTMZ_CY,代码行数:7,代码来源:专项救助_低保边缘户.cs

示例4: Save

        public bool Save(DB.Stru.福利中心.老人费用退费管理 stru)
        {
            string strID =  Orm.Save(stru);
            stru.ID = strID;

            return ! String.IsNullOrEmpty(strID);
        }
开发者ID:cheng521yun,项目名称:FTMZ,代码行数:7,代码来源:老人费用退费管理.cs

示例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;
				}
			}
		}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:38,代码来源:GitHubNotification.cs

示例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();
         }
     }
 }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:25,代码来源:ManagerDutyTime.aspx.cs

示例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;
 }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:29,代码来源:ManagerDutyTime.aspx.cs

示例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();
 }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:7,代码来源:JsManagerMain.aspx.cs

示例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.备注 ;
        }
开发者ID:cheng521yun,项目名称:https---github.com-frontflag-FTMZ_CY,代码行数:27,代码来源:伤残人员_基本信息.cs

示例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;
        }
    }
开发者ID:ZRUIK,项目名称:SETC,代码行数:31,代码来源:SubMenu_Del.aspx.cs

示例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;
            }
        }
开发者ID:Enumeg,项目名称:POS-General,代码行数:35,代码来源:Categories.xaml.cs

示例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();
          }
            }

        }
    }
开发者ID:ZRUIK,项目名称:SETC,代码行数:33,代码来源:User_Add.aspx.cs

示例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();
        }
开发者ID:bsimp6983,项目名称:BackupDashes,代码行数:28,代码来源:TvDemoControl.aspx.cs

示例14: SInsert

 public static int SInsert(string sql, params object[] parameter)
 {
     using (DB db = new DB())
     {
         return db.Insert(sql, parameter);
     }
 }
开发者ID:nokitty,项目名称:chaxin,代码行数:7,代码来源:DB.cs

示例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;
    }
开发者ID:LiuYingyingCSU,项目名称:JobskyOA,代码行数:30,代码来源:ScoreRank.aspx.cs


注:本文中的DB类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。