Exemple #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrEmpty(txtDes.Text))
         {
             throw new Exception("Enter Description");
         }
         if (string.IsNullOrEmpty(txtAmount.Text))
         {
             throw new Exception("Enter Amount");
         }
         expense.insert(txtDes, txtAmount, dateTimeDate);
         expense.DisplayAll(dataGridExpense);
         txtAmount.Text         = "";
         txtDes.Text            = "";
         lblID.Text             = "";
         dateTimeDate.Value     = dataAccess.Sdate;
         dataAccess.Description = "Made An Expense";
         dataAccess.Activities();
     }
     catch (Exception Ex)
     {
         MessageBox.Show(Ex.Message + "Operation Failed", "Report", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #2
0
 private void txtcost_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyValue == (char)Keys.Enter)
     {
         try
         {
             if (string.IsNullOrEmpty(txtexpensename.Text))
             {
                 throw new Exception("Enter Name for the Expense ");
             }
             else if (string.IsNullOrEmpty(txtcost.Text))
             {
                 throw new Exception("Enter Amount for Expense ");
             }
             Expenses expense = new Expenses();
             expense.insert(txtexpensename, txtcost, dateTimeDate);
             dataAccess.Description = "Made an Expense";
             dataAccess.Activities();
             MessageBox.Show("Expense Recorded", "Expense", MessageBoxButtons.OK, MessageBoxIcon.Information);
             txtcost.Text        = "";
             txtexpensename.Text = "";
         }
         catch (Exception Ex)
         {
             MessageBox.Show(Ex.Message + "\nExpense Record Failed", "Expense", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }