コード例 #1
0
 private void ShowInfo(int ID)
 {
     lifesense.BLL.t_userinfo   userbll = new BLL.t_userinfo();
     lifesense.Model.t_userinfo model   = userbll.GetModel(ID);
     txtFUserID.Text   = model.UserID;
     txtFUserName.Text = model.UserName;
     txtUserPwd.Text   = model.UserPwd;
     lblID.Text        = model.ID.ToString();
 }
コード例 #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool bolResult = false;

            lifesense.BLL.t_userinfo   userbll = new BLL.t_userinfo();
            lifesense.Model.t_userinfo model   = new Model.t_userinfo();
            model.UserID   = txtFUserID.Text.Trim();
            model.UserName = txtFUserName.Text.Trim();
            model.UserPwd  = DESEncrypt.Encrypt(txtUserPwd.Text.Trim());
            if (!string.IsNullOrEmpty(lblID.Text))
            {
                model.ID = Convert.ToInt32(lblID.Text);
                if (userbll.GetModel(model.ID).UserID == model.UserID)
                {
                    bolResult = userbll.Update(model);
                }
                else
                {
                    Maticsoft.Common.MessageBox.Show(this, "已经存在相同的用户ID,请重新输入过!");
                    txtFUserID.Focus();
                }
            }
            else
            {
                if (userbll.GetRecordCount(string.Format("UserID='{0}'", model.UserID)) > 0)
                {
                    Maticsoft.Common.MessageBox.Show(this, "已经存在相同的用户ID,请重新输入过!");
                    txtFUserID.Focus();
                }
                else
                {
                    if (userbll.Add(model) > 0)
                    {
                        bolResult = true;
                    }
                }
            }
            if (bolResult)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "success", "<script language=javascript>alert('保存成功!');window.location='UserList.aspx';</script>");
                //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script>alert('你输入的原来密码有误,请重输!');</script>");
                //Response.Redirect("UserListForm.aspx");
            }
        }
コード例 #3
0
        private void LoadData()
        {
            lifesense.BLL.t_userinfo userbll = new BLL.t_userinfo();
            StringBuilder            sb      = new StringBuilder();

            if (!string.IsNullOrEmpty(ddltimType.Text.Trim()))
            {
                sb.AppendFormat("and cast ({0} as date) between '{1}' and '{2}'", ddltimType.SelectedValue.ToString(), Convert.ToDateTime(txtstartime.Text).ToString("yyyy-MM-dd"), Convert.ToDateTime(txtenddate.Text).ToString("yyyy-MM-dd"));
            }
            if (!string.IsNullOrEmpty(txtUserID.Text.Trim()))
            {
                sb.AppendFormat("and u.UserID like '%{0}%' ", txtUserID.Text.Trim());
            }
            string     sql = string.Format(@"SELECT u.UserID AS 用户ID,
                                           w.MeasureTime AS 测量时间,
                                           w.StepNum AS 步数,
                                           w.Calorie AS 卡里路,
                                           w.Mileage AS 里程,
                                           s.SleepingTime AS 入睡时间,
                                           s.WakingTime AS 醒来时间,
                                           s.LongSleepNum AS '深睡时长(分钟)',
                                           s.ShallowSleepNum AS '浅睡时长(分钟)',
                                           s.WakeUpLong AS '醒来时长(分钟)',
                                           s.WakingNum AS 醒来次数,
                                           h.StartTime AS '心率测量开始时间',
                                           h.HeartRate AS '心率'
                                    FROM t_userinfo AS u
                                         LEFT JOIN t_walkinfo AS w ON u.UserID = w.UserID 
                                         LEFT JOIN t_sleepinfo AS s ON u.UserID = s.UserID and cast(w.MeasureTime as date)=cast(s.SleepingTime as date)
                                         LEFT JOIN t_heartrateinfo AS h ON u.UserID = h.UserID and cast(s.SleepingTime as date)=  cast(h.StartTime as date)  where 1=1 {0} ", sb.ToString());
            DataSet    ds2 = userbll.GetSqlList(sql);
            DataSet    ds  = userbll.ExecuteSqlPager(sql, "测量时间,用户ID", AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize);
            DataColumn dc;

            for (int i = 1; i <= 288; i++)
            {
                dc = new DataColumn("心率" + i.ToString(), typeof(Int32));
                ds.Tables[0].Columns.Add(dc);
            }
            for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
            {
                if (ds.Tables[0].Rows[j]["心率"] != null && ds.Tables[0].Rows[j]["心率"].ToString() != "")
                {
                    for (int i = 1; i <= 288; i++)
                    {
                        ds.Tables[0].Rows[j]["心率" + i.ToString()] = Convert.ToInt32(ds.Tables[0].Rows[j]["心率"].ToString().Substring((i - 1) * 2, 2), 16);
                    }
                }
            }
            ds.Tables[0].AcceptChanges();
            for (int i = 1; i <= 288; i++)
            {
                BoundField column = new BoundField();
                column.HeaderText      = "心率" + i.ToString();
                column.DataField       = "心率" + i.ToString();//数据字段名称(类的属性)
                column.ItemStyle.Width = 50;
                gvStatic.Columns.Add(column);
            }
            gvStatic.DataSource = ds.Tables[0];

            gvStatic.DataBind();
            int RecordCount = ds2.Tables[0].Rows.Count;

            AspNetPager1.RecordCount = RecordCount;
        }