Ejemplo n.º 1
0
        public WeightRecord GetOldestWeightRecord(int UserID)
        {
            string command = "EXECUTE dbo.OldestWeightForUserID @UserID";

            WeightRecord result = null;

            using (var conn = new SqlConnection(connString))
            {
                result = conn.QueryFirstOrDefault <WeightRecord>(command, new { UserID });
            }

            return(result);
        }
        public object UpdateWeightRecord(WeightRecord weightRecord)
        {
            int result = weightData.UpdateWeightRecord(weightRecord);

            if (result == 1)
            {
                return(new { Success = true, Message = "User updated" });
            }
            else
            {
                return(new { Success = false, Message = "Something went wrong, user did not update" });
            }
        }
Ejemplo n.º 3
0
        public bool WeightRecordExistsforDate(WeightRecord weightRec)
        {
            string command = "EXECUTE dbo.SelectRecordByUserIDAndDate @UserID, @WeightInDate";

            WeightRecord result = null;

            using (var conn = new SqlConnection(connString))
            {
                result = conn.QueryFirstOrDefault <WeightRecord>(command, weightRec);
            }

            return(result != null);
        }
Ejemplo n.º 4
0
        public WeightRecord AddWeightRecord(WeightRecord weightRecord)
        {
            string command = "EXECUTE dbo.AddWeightRecord @UserID, @WeightInDate, @CurrentWeight";

            WeightRecord result = null;

            using (var conn = new SqlConnection(connString))
            {
                result = conn.QueryFirstOrDefault <WeightRecord>(command, weightRecord);
            }

            return(result);
        }
Ejemplo n.º 5
0
        public int UpdateWeightRecord(WeightRecord weightRecord)
        {
            string command = "EXECUTE dbo.UpdateExistingWeightRecord @UserID, @WeightInDate, @CurrentWeight";

            int result;

            using (var conn = new SqlConnection(connString))
            {
                result = conn.Execute(command, weightRecord);
            }

            return(result);
        }
Ejemplo n.º 6
0
 public WeightSpan(WeightRecord record1, WeightRecord record2)
 {
     if (record1.MeasuredAt < record2.MeasuredAt)
     {
         From   = record1.MeasuredAt;
         To     = record2.MeasuredAt;
         Change = record2.Value - record1.Value;
     }
     else
     {
         From   = record2.MeasuredAt;
         To     = record1.MeasuredAt;
         Change = record1.Value - record2.Value;
     }
 }
Ejemplo n.º 7
0
        public void NumberOfRecordsShouldIncreaseWhenIAddRecord()
        {
            var userName = "******";
            var service  = new PerfectLifeWebServiceClient();

            var records1 = service.GetRecords(userName).Result.Count;

            var record = new WeightRecord(userName, 80);
            var result = service.AddRecord(record);

            Assert.Equal(HttpStatusCode.OK, result.Result);

            var records2 = service.GetRecords(userName).Result.Count;

            Assert.Equal(records1 + 1, records2);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 双击皮重记录,显示历史皮重
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pzDataGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Point            aP     = e.GetPosition(pzDataGrid);
            IInputElement    obj    = pzDataGrid.InputHitTest(aP);
            DependencyObject target = obj as DependencyObject;

            while (target != null)
            {
                if (target is DataGridRow)
                {
                    WeightRecord sp = pzDataGrid.SelectedItem as WeightRecord;
                    ShowHistoryTare(sp);
                    break;
                }
                target = VisualTreeHelper.GetParent(target);
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// 查看录像
 /// </summary>
 /// <param name="wm">称量记录</param>
 /// <param name="showType">查看类型(0:净重;1:皮重;2:毛重)</param>
 public ShowVideoTapeView(WeightRecord wm, int showType)
 {
     InitializeComponent();
     if (showType == 0)
     {
         FormNameTextBlock.Text = "净重记录_查看录像";
     }
     else if (showType == 1)
     {
         FormNameTextBlock.Text = "皮重记录_查看录像";
     }
     else if (showType == 2)
     {
         FormNameTextBlock.Text = "毛重记录_查看录像";
     }
     weightModel = wm;
     LoadDefaultTime();
     this.showType = showType;
 }
Ejemplo n.º 10
0
        public ActionResult Create(WeightRecord r2)
        {
            WeightRecord r = new WeightRecord();

            try
            {
                r.UserName = User.Identity.Name;

                UpdateModel(r);

                int newId = weightRecords.Add(r);

                return(RedirectToAction("Details", new { id = newId }));
            }
            catch
            {
                ModelState.AddRuleViolations(r.GetRuleViolations());
                return(View(r));
            }
        }
Ejemplo n.º 11
0
 public Task <int> RemoveWeightAsync(WeightRecord weightRecord) =>
 Connection.DeleteAsync(weightRecord);
Ejemplo n.º 12
0
 public Task <int> UpdateWeightRecordAsync(WeightRecord weightRecord) =>
 Connection.UpdateAsync(weightRecord);
Ejemplo n.º 13
0
 public Task <int> InsertWeightRecordAsync(WeightRecord weightRecord) =>
 Connection.InsertAsync(weightRecord);