public void AddTitheRecord(TitheRecord tithe)
 {
     if (this.bll.AddTitheRecord(tithe))
     {
         this.view.ShowMessage("Successfully added tithe record.");
     }
     else
     {
         this.view.ShowMessage("Error adding tithe record.");
     }
 }
 public bool AddTitheRecord(TitheRecord tithe)
 {
     try
     {
         return this.dll.CreateTitheRecord(tithe);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var record = new TitheRecord();

            record.memberId = this.GetSelectedMember().id;
            record.recordDate = this.dtpDate.Value;
            record.amount = this.ParseDecimalFromAmount();
            record.checkNum = this.txtCheckNumb.Text;
            record.pamyentType = this.GetSelectedType().id;
            record.type = this.ParseTitheType();

            this.controller.AddTitheRecord(record);
        }
        public bool CreateTitheRecord(TitheRecord tithe)
        {
            using (OleDbConnection con = new OleDbConnection(this.connectionString))
            {
                con.Open();

                using (OleDbCommand cmd = new OleDbCommand("INSERT INTO TitheRecords (memberId, recordDate, paymentType, checkNumber, amount, recordType) VALUES " +
                    "(@memberId, @recordDate, @paymentType, @checkNumber, @amount, @recordType)", con))
                {
                    OleDbParameter memberId = new OleDbParameter("@memberId", OleDbType.Integer);
                    memberId.Value = tithe.memberId;
                    cmd.Parameters.Add(memberId);

                    OleDbParameter recordDate = new OleDbParameter("@recordDate", OleDbType.Date);
                    recordDate.Value = tithe.recordDate;
                    cmd.Parameters.Add(recordDate);

                    OleDbParameter paymentType = new OleDbParameter("@paymentType", OleDbType.Integer);
                    paymentType.Value = tithe.pamyentType;
                    cmd.Parameters.Add(paymentType);

                    OleDbParameter checkNum = new OleDbParameter("@checkNumber", OleDbType.VarChar);
                    checkNum.Value = tithe.checkNum;
                    cmd.Parameters.Add(checkNum);

                    OleDbParameter amount = new OleDbParameter("@amount", OleDbType.Decimal);
                    amount.Value = tithe.amount;
                    cmd.Parameters.Add(amount);

                    OleDbParameter type = new OleDbParameter("@recordType", OleDbType.VarChar);
                    type.Value = tithe.type;
                    cmd.Parameters.Add(type);

                    int numRows = cmd.ExecuteNonQuery();

                    return numRows != 0;
                }
            }
        }