Esempio n. 1
0
        // update cash expenses record
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                model.Description   = txtDescription.Text.Trim();
                model.VoucherNumber = txtVoucherNum.Text.Trim();
                model.Reference     = txtReference.Text.Trim();
                model.Amount        = Convert.ToDecimal(txtAmount.Text.Trim());

                using (CashbookEntities db = new CashbookEntities())
                {
                    //update selected/existing customer record
                    db.Entry(model).State = EntityState.Modified;
                    db.SaveChanges();
                }
                Clear();
                PopulateData();
                MessageBox.Show("Record Updated Successfully");
                panel1.Visible = false;
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Search"); //excep.GetType().ToString()
            }
        }
Esempio n. 2
0
        // save new expense
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                model.Date = dtDate.Value.Date;

                //model.Date = Convert.ToDateTime(dtDate.Text.Trim());
                model.Description   = txtDescription.Text.Trim();
                model.VoucherNumber = txtVoucherNum.Text.Trim();
                model.Reference     = txtReference.Text.Trim();
                model.Amount        = Convert.ToDecimal(txtAmount.Text.Trim());

                using (CashbookEntities db = new CashbookEntities())
                {
                    //add new expense record
                    db.Expenses.Add(model);
                    db.SaveChanges();
                }
                Clear();
                MessageBox.Show("New Cash Expense Saved Successfully");
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Search"); //excep.GetType().ToString()
            }
        }