Ejemplo n.º 1
0
        public PaymentBo Get(int id)
        {
            using (SqlConnection conn = CreateConnection())
            {
                using (SqlCommand cmd = CreateSpCommand("spPaymentGet", conn))
                {
                    cmd.Parameters.AddWithValue("@Id", id);
                    cmd.AddVarCharOutParam("@PaymentType", 200);
                    cmd.AddDateTimeOutParam("@PaymentDate");
                    cmd.AddDecimalOutParam("@Amount", 16, 2);
                    cmd.AddDateTimeOutParam("@CreationDate");
                    cmd.AddDateTimeOutParam("@ChangeDate");
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();

                    var bo = new PaymentBo();
                    bo.Id = id;
                    bo.PaymentType = cmd.GetParamValue<int>("@PaymentType");
                    bo.PaymentDate = cmd.GetParamValue<DateTime>("@PaymentDate");
                    bo.Amount = cmd.GetParamValue<decimal>("@PaymentDate");
                    bo.CreationDate = cmd.GetParamValue<DateTime>("@CreationDate");
                    bo.ChangeDate = cmd.GetParamValue<DateTime>("@ChangeDate");
                    return bo;
                }
            }
        }
Ejemplo n.º 2
0
 public void Save(PaymentBo bo)
 {
     if (bo.IsNewRecord)
     {
         Insert(bo);
     }
     else
     {
         Update(bo);
     }
 }
Ejemplo n.º 3
0
        private void Insert(PaymentBo bo)
        {
            using (SqlConnection conn = CreateConnection())
            {
                using (SqlCommand cmd = CreateSpCommand("spPaymentIns", conn))
                {
                    cmd.AddIntOutParam("@Id");
                    cmd.Parameters.AddWithNullableValue("@PaymentType", bo.PaymentType);
                    cmd.Parameters.AddWithNullableValue("@PaymentDate", bo.PaymentDate);
                    cmd.Parameters.AddWithValue("@Amount", bo.Amount);
                    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");
                }
            }
        }
Ejemplo n.º 4
0
 public void SetCurrentId(int currentId)
 {
     _currentPaymentBo = _paymentRepository.Get(currentId);
 }