示例#1
0
        public ReceiptBo Get(int id)
        {
            using (SqlConnection conn = CreateConnection())
            {
                using (SqlCommand cmd = CreateSpCommand("spReceiptGet", conn))
                {
                    cmd.Parameters.AddWithValue("@Id", id);

                    cmd.AddDecimalOutParam("@Amount", 16, 2);
                    cmd.AddDateTimeOutParam("@Date");
                    cmd.AddDateTimeOutParam("@CreationDate");
                    cmd.AddDateTimeOutParam("@ChangeDate");

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();

                    var bo = new ReceiptBo();
                    bo.Id = id;
                    bo.Amount = cmd.GetParamValue<decimal>("@Amount");
                    bo.Date = cmd.GetParamValue<DateTime>("@Date");
                    bo.CreationDate = cmd.GetParamValue<DateTime>("@CreationDate");
                    bo.ChangeDate = cmd.GetParamValue<DateTime>("@ChangeDate");
                    return bo;
                }
            }
        }
示例#2
0
 private void SaveReceipt()
 {
     if (_currentReceipt == null)
     {
         _currentReceipt = new ReceiptBo();
     }
     _currentReceipt.Amount = clcValue.Value;
     _currentReceipt.Date = dateEditDate.DateTime;
     _receiptRepository.Save(_currentReceipt);
 }
示例#3
0
 public void Save(ReceiptBo bo)
 {
     if (bo.IsNewRecord)
     {
         Insert(bo);
     }
     else
     {
         Update(bo);
     }
 }
示例#4
0
        private void Insert(ReceiptBo bo)
        {
            using (SqlConnection conn = CreateConnection())
            {
                using (SqlCommand cmd = CreateSpCommand("spReceiptIns", conn))
                {
                    cmd.AddIntOutParam("@Id");
                    cmd.Parameters.AddWithValue("@Amount", bo.Amount);
                    cmd.Parameters.AddWithValue("@Date", bo.Date);
                    cmd.AddDateTimeOutParam("@CreationDate");
                    cmd.AddDateTimeOutParam("@ChangeDate");

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();

                    bo.Id = cmd.GetParamValue<int>("@Id");
                    bo.CreationDate = cmd.GetParamValue<DateTime>("@CreationDate");
                    bo.ChangeDate = cmd.GetParamValue<DateTime>("@ChangeDate");
                }
            }
        }
示例#5
0
 public void SetCurrentId(int currentId)
 {
     _currentReceipt = _receiptRepository.Get(currentId);
 }