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


C# DBHelper类代码示例

本文整理汇总了C#中DBHelper的典型用法代码示例。如果您正苦于以下问题:C# DBHelper类的具体用法?C# DBHelper怎么用?C# DBHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DBHelper类属于命名空间,在下文中一共展示了DBHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: QueryTest

        public void QueryTest()
        {
            // Arrange-测试设置,创建对象
            DBHelper db = new DBHelper();
            Customer customer = new Customer()
                                               {
                                                   UserName = "User-1",
                                                   Password = "PWDHASH-1 ",
                                                   Email = "EMAIL-1 ",
                                                   PhoneNumber = "PHONE-1 ",
                                                   IsFirstTimeLogin = false,
                                                   AccessFailedCount = 0,
                                                   CreationDate = DateTime.Now,
                                                   IsActive = false
                                               };
            int count = 0;
            List<Customer> customerList = new List<Customer>();

            // 拼接字符串的时候要注意标量的名字要与类中的成员变量名一样(可忽略字母的大小写)
            // 例如:此处sql中的@Password中的Password就必须与Customer类中的成员变量Password名称一样(可忽略大小写)
            string querySQL = @"SELECT * FROM dbo.CICUser WHERE [email protected] AND [email protected]";

            // Act-测试行为,使用功能
            customerList = db.Query<Customer>(querySQL, customer).ToList();
            count = customerList.Count;

            // Assert-测试结果,验证结果
            Assert.AreEqual(1,count);
        }
开发者ID:AllenSteve,项目名称:Instance,代码行数:29,代码来源:DapperApiUnitTest.cs

示例2: clearDB

 public void clearDB(Context context)
 {
     dbHelper = new DBHelper(context);
     SQLiteDatabase db = dbHelper.WritableDatabase;
     db.Delete("general", null, null);
     db.Delete("records", null, null);
 }
开发者ID:JustLex,项目名称:CourseTask,代码行数:7,代码来源:DatabaseController.cs

示例3: getRecordsInfo

        public RecordInfo getRecordsInfo(String difficulty, Context context)
        {
            dbHelper = new DBHelper(context);
            SQLiteDatabase db = dbHelper.WritableDatabase;
            SQLiteCursor gc = (SQLiteCursor)db.Query("general", null, "difficulty = ?", new String[]{difficulty}, null, null, null);
            int avgTimeColIndex = gc.GetColumnIndex("avgTime");
            int gamesCountColIndex = gc.GetColumnIndex("gamesCount");
            int avgTime = 0;
            int gamesCount = 0;
            if (gc.MoveToFirst()){
                avgTime = gc.GetInt(avgTimeColIndex);
                gamesCount = gc.GetInt(gamesCountColIndex);
            }
            RecordInfo result = new RecordInfo(avgTime, gamesCount, new Java.Lang.String(difficulty));
            SQLiteCursor c = (SQLiteCursor)db.Query("records", null, " difficulty = ?", new String[]{difficulty}, null, null, null);
            if (c.MoveToFirst()) {
                int timeColIndex = c.GetColumnIndex("time");

                result.addRecord(c.GetInt(timeColIndex));
                while (c.MoveToNext()) {
                    result.addRecord(c.GetInt(timeColIndex));
                }
            }
            return result;
        }
开发者ID:JustLex,项目名称:CourseTask,代码行数:25,代码来源:DatabaseController.cs

示例4: ImportItem

        public ImportItem(IProject project, DBHelper dbHelper)
        {
            this._TheProject = project;
            this.DBHelper = dbHelper;

            this.TheProject.TargetDateChanged += this.OnDateChanged;
        }
开发者ID:GemHu,项目名称:ExportManager,代码行数:7,代码来源:ImportItem.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            #region 标签信息
            string strTagInfo = "";

            try
            {
                string sql = "select * from [tb_tag] where tag_ispublic=1";
                DataTable dt = new DataTable();
                DBHelper dbh = new DBHelper(config.DBConn);
                dt = dbh.ExecuteDataTable("", sql);

                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        strTagInfo += "<a href=\"default.aspx?id=" + dt.Rows[i]["tag_id"].ToString() + "\" class=\"tag\" target=\"_blank\">" + dt.Rows[i]["tag_name"].ToString() + "</a>";
                    }
                }

                dbh.Dispose();
                dt.Dispose();
            }
            catch (Exception ex)
            {
                strTagInfo = ex.ToString();
            }

            this.tagBall.InnerHtml = strTagInfo;

            #endregion
        }
开发者ID:juxiaoqi,项目名称:LongmaoSite,代码行数:32,代码来源:tags.aspx.cs

示例6: GetYourDates

    internal DateTime[] GetYourDates(DBHelper db_, TZ tz_)
    {
      string tableName = "eventTimesGMT";

      switch (tz_)
      {
        case TZ.HK: tableName = "eventTimesHK"; break;
        case TZ.LN: tableName = "eventTimesLN"; break;
        case TZ.NY: tableName = "eventTimesNY"; break;
        case TZ.GMT: tableName = "eventTimesGMT"; break;

      }

      var sql = string.Format("select eventTimeLocal from {1} where eventID={0} order by eventTimeGMT", EventID, tableName);

      var ds = db_.Execute(sql);

      if (DBHelper.HasData(ds))
      {
        var list = new List<DateTime>();

        foreach (DataRow row in ds.Tables[0].Rows)
          list.Add((DateTime)row[0]);

        return list.ToArray();
      }

      return null;
    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:29,代码来源:EventGroup.cs

示例7: GetUserID

        public List<string> GetUserID(string mode, string user_id)
        {
            List<string> lst = new List<string>();

            DBHelper helper = new DBHelper();
            SqlParameter[] param = new SqlParameter[2];
            param[0] = new SqlParameter(CONSTANT.MODE, mode);
            param[1] = new SqlParameter(CONSTANT.USER_ID, user_id);
            DataSet ds = helper.executeSelectQuery(PROCEDURES.DELETE_USER_OPERTAION, param);
            if (ds != null)
            {

                foreach (DataRow item in ds.Tables[0].Rows)
                {


                    lst.Add(item[0].ToString());


                }
            }

            return lst;

        }
开发者ID:DevopsRizwan,项目名称:grpt,代码行数:25,代码来源:SuperAdminBLL.cs

示例8: HoborAsker

        //const double AllowRange = 0.5;
        public static HoborModel HoborAsker(DBHelper DBHelper,  double XAxis, double YAxis)
        {
            HoborModel result=new HoborModel();
            double AllowRange = GetConfig.GetAllowRange();
            double xAxisAbove = XAxis + AllowRange
                , xAxisBelow = XAxis - AllowRange
                , yAxisAbove = YAxis + AllowRange
                , yAxisBelow = YAxis - AllowRange;

            string commandText = "SELECT * FROM Hobor WHERE XAxis BETWEEN @XAxis1 AND @XAxis2 AND YAxis Between @YXias1 AND @YXias2";
            System.Data.DataTable dt = DBHelper.GetData(commandText, new List<Parameter>()
            {
                new Parameter("@XAxis1",xAxisBelow)
                ,new Parameter("@XAxis2",xAxisAbove)
                ,new Parameter("@YXias1",yAxisBelow)
                ,new Parameter("@YXias2", yAxisAbove)
            });
            if (dt != null && dt.Rows.Count > 0)
            {
                result.IsExist = true;
                result.CountryName = dt.Rows[0]["CountryName"].ToString();
                result.Name = dt.Rows[0]["Name"].ToString();
                result.XAxis = Common.ConvertToDouble(dt.Rows[0]["XAxis"]);
                result.YAxis = Common.ConvertToDouble(dt.Rows[0]["YAxis"]);
                result.Info = dt.Rows[0]["Info"].ToString();
            }
            return result;
        }
开发者ID:hwwen,项目名称:Hobor,代码行数:29,代码来源:HoborModel.cs

示例9: ListHitViewer

        public ListHitViewer()
        {
            InitializeComponent();
            db = new DBHelper();

            //load up the app bar
            ApplicationBar = new ApplicationBar();

            ApplicationBar.Mode = ApplicationBarMode.Minimized;
            ApplicationBar.Opacity = 1.0;
            ApplicationBar.IsVisible = true;
            ApplicationBar.IsMenuEnabled = true;

            //get the item from the phone state!  woo!
            if (PhoneApplicationService.Current.State.ContainsKey("CurrentItem") && PhoneApplicationService.Current.State["CurrentItem"] != null)
            {
                _item = PhoneApplicationService.Current.State["CurrentItem"] as OldItem;

                //only show share if the _item is not null
                ApplicationBarIconButton btnShareAppBar = new ApplicationBarIconButton();
                btnShareAppBar.IconUri = new Uri("/Assets/AppBarIcons/share.png", UriKind.Relative);
                btnShareAppBar.Text = "Tap To Share";
                ApplicationBar.Buttons.Add(btnShareAppBar);
                btnShareAppBar.Click += new EventHandler(btnShareAppBar_Click);
            }

            //feedback button
            ApplicationBarIconButton btnFeedbackAppBar = new ApplicationBarIconButton();
            btnFeedbackAppBar.IconUri = new Uri("/Assets/AppBarIcons/questionmark.png", UriKind.Relative);
            btnFeedbackAppBar.Text = "Feedback";
            ApplicationBar.Buttons.Add(btnFeedbackAppBar);
            btnFeedbackAppBar.Click += new EventHandler(btnFeedbackAppBar_Click);
        }
开发者ID:Frannsoft,项目名称:dnd35encyclopedia,代码行数:33,代码来源:ListHitViewer.xaml.cs

示例10: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (string.IsNullOrWhiteSpace(Request.QueryString["Exhibition"])) return;

            string strExhibitionId = Request.QueryString["Exhibition"];

            DBHelper objHelper = new DBHelper();
            General objGen = new General();

            string strSQL = @"SELECT EXHIBITION_NAME,
                                     EXHIBITION_DETAILS,
                                     EXHIBITON_TEXT,
                                     EXHIBITION_IMAGE
                              FROM   INSTA_MST_EXHIBITION
                              WHERE  EXHIBITION_ID =" + objGen.gReplaceQuotes(strExhibitionId);
            IDataReader reader = objHelper.gExecuteReader(CommandType.Text, strSQL);
            while (reader.Read())
            {

                img.Src = "../../upload/images/Exhibition/" + Convert.ToString(reader["EXHIBITION_IMAGE"]);
                ltHeading.Text = Convert.ToString(reader["EXHIBITION_NAME"]) + Convert.ToString(reader["EXHIBITION_DETAILS"]);
                ltDetail.Text = Convert.ToString(reader["EXHIBITON_TEXT"]);
            }
            reader.Close();
            reader.Dispose();

        }
    }
开发者ID:shreykejriwal,项目名称:insta,代码行数:30,代码来源:iExhibitions.aspx.cs

示例11: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Url.Host.ToLower() == "localhost")
            {
                //base.login_user_id = 40123; //user
                //base.login_user_id = 40110; //exec producer -- skip
                //base.login_user_id = 272; //producer -- elyse
                //base.login_user_id = 205; //coordinator
                base.login_user_id = 144; //administrator -- randy
                theader.Visible = false;
                aheader.Visible = false;
                levaNav.Visible = false;
                tfooter.Visible = false;
                levbNav.Visible = false;
                groupTest = this.TestGroupMembership;
            }
            else
            {
                base.Page_Load("/newallocations/LockAllocations.aspx");
                groupTest = base.testmembership;
            }
            DBHelper db = new DBHelper();
            if (!groupTest.Invoke(ref db, "A3Coordinator") && !groupTest.Invoke(ref db, "A2Administrator"))
                Response.Redirect("/permitError.html");

            int week_num = RGA.Allocations.Data.Utility.CurrectWeek() + 1;
            WeekNumber.Value = week_num.ToString();
            Week.Text = RGA.Allocations.Data.Utility.CurrectWeekStartDate(week_num).ToString("MM/dd/yy");
        }
开发者ID:the0ther,项目名称:how2www.info,代码行数:29,代码来源:LockAllocations.aspx.cs

示例12: AddBudget

        DBHelper helper;  // 和数据库打交道

        public AddBudget(string name)
        {
            InitializeComponent();
            currentUser = name;
            helper = new DBHelper();
            initialize();
        }
开发者ID:shoumu,项目名称:Pigger,代码行数:9,代码来源:AddBudget.xaml.cs

示例13: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            IsInGroup groupTest = null;
            if (Request.Url.Host.ToLower() == "localhost")
            {
                //base.login_user_id = _UserId = 40123; //user
                //base.login_user_id = _UserId = 40110; //exec producer -- skip
                //base.login_user_id = _UserId = 272; //producer -- elyse
                //base.login_user_id = _UserId = 205; //coordinator
                base.login_user_id = _UserId = 144; //administrator -- randy

                theader.Visible = false;
                aheader.Visible = false;
                levaNav.Visible = false;
                tfooter.Visible = false;
                levbNav.Visible = false;
                groupTest = TestGroupMembership;
            }
            else
            {
                base.Page_Load("/newallocations/TeamAllocation.aspx");
                _UserId = base.login_user_id;
                groupTest = base.testmembership;
            }

            // determine if the user's group and set a variable to use when printing out allocations
            DBHelper db = new DBHelper();
            if (groupTest.Invoke(ref db, "A3Coordinator"))
                _secType = RgaWeb.SecurityType.EditAll;
            if (groupTest.Invoke(ref db, "A2Administrator"))
                _secType = RgaWeb.SecurityType.EditAll;
            if (groupTest.Invoke(ref db, "A8Producer"))
                _secType = RgaWeb.SecurityType.EditUpcoming;
            if (groupTest.Invoke(ref db, "A5ExecProducer"))
                _secType = RgaWeb.SecurityType.EditUpcoming;

            if (!Page.IsPostBack)
            {
                LoadRegions();
                LoadDepartments();

                // retrieve current week and date 
                _StartWeek = RgaData.Utility.CurrectWeek();
                _StartDate = RgaData.Utility.CurrectWeekStartDate(_StartWeek);

                // setup week picker
                ctlWeekPicker.CurrentWeek = _StartWeek;
                ctlWeekPicker.CurrectWeekStartDate = _StartDate;
            }
            else
            {
                // set start week
                _StartWeek = ctlWeekPicker.CurrentWeek;
            }

            // set up delegate to rebind the grid when week selection is changed
            DelSelectWeek delSelectWeek = new DelSelectWeek(this.ctlWeekPicker_SelectedIndexChanged);
            ctlWeekPicker.UpdateCurrentWeek = delSelectWeek;
        }
开发者ID:the0ther,项目名称:how2www.info,代码行数:59,代码来源:RegionAllocation.aspx.cs

示例14: Test

 public bool Test()
 {
     SqlParameter[] param = new SqlParameter[1];
     DBHelper helper = new DBHelper();
     param[0] = new SqlParameter(CONSTANT.CAT_ID, "ZCVV");
     bool ds = helper.InsertQuery(PROCEDURES.CAT_INSERT, param);
     return ds;
 }
开发者ID:grocerspoint,项目名称:gprepo,代码行数:8,代码来源:ProductAdminBLL.cs

示例15: putRecord

        public void putRecord(long time, String difficulty, Context context)
        {
            dbHelper = new DBHelper(context);
            ContentValues cv = new ContentValues();
            SQLiteDatabase db = dbHelper.WritableDatabase;
            SQLiteCursor c = (SQLiteCursor)db.Query("records", null, " difficulty = ?", new String[]{difficulty}, null, null, null);
            int count = 1;
            if (c.MoveToFirst()) {

                int idColIndex = c.GetColumnIndex("id");
                int timeColIndex = c.GetColumnIndex("time");

                int maxDBindex = c.GetInt(idColIndex);
                int maxDBtime = c.GetInt(timeColIndex);
                count++;
                while (c.MoveToNext()) {
                    if (c.GetInt(timeColIndex) > maxDBtime){
                        maxDBtime = c.GetInt(timeColIndex);
                        maxDBindex = c.GetInt(idColIndex);
                    }
                    count++;
                }
                if (count == 6){
                    if (time < maxDBtime){
                        db.Delete("records", " id = ?", new String[]{maxDBindex + ""});
                    } else {
                        c.Close();
                        db.Close();
                        return;
                    }
                }
            }
            cv.Put("time", time);
            cv.Put("difficulty", difficulty);
            db.Insert("records", null, cv);
            cv.Clear();

            SQLiteCursor gc = (SQLiteCursor)db.Query("general", null, "difficulty = ?", new String[]{difficulty}, null, null, null);
            gc.MoveToFirst();
            int avgTimeColIndex = gc.GetColumnIndex("avgTime");
            int gamesCountColIndex = gc.GetColumnIndex("gamesCount");
            int avgTime = 0;
            int gamesCount = 0;
            if (gc.MoveToFirst()){
                avgTime = gc.GetInt(avgTimeColIndex);
                gamesCount = gc.GetInt(gamesCountColIndex);
            }
            int newGamesCount = gamesCount + 1;
            int newAvgTime = (avgTime * gamesCount / newGamesCount) + (int)(time / newGamesCount);
            cv.Put("difficulty", difficulty);
            cv.Put("avgTime", newAvgTime);
            cv.Put("gamesCount", newGamesCount);
            db.Delete("general", " difficulty = ?", new String[]{difficulty});
            db.Insert("general", null, cv);
            db.Close();
            c.Close();
            gc.Close();
        }
开发者ID:JustLex,项目名称:CourseTask,代码行数:58,代码来源:DatabaseController.cs


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