コード例 #1
0
        private void cbxCategory_DropDownClosed(object sender, EventArgs e)
        {
            if (cbxCategory.SelectedItem.ToString() == "<Select Category>")
            {
                DataObjectsInitializer.checkDatabaseConnection();
                DataRow IDRow = DatabaseConnectionObject.datasetObject_Global.Tables["TableIDNmbers"].Rows.Find("TabExp");
                lblExpID.Text = IDRow["Table Prefix"].ToString() + IDRow["Next ID Number"].ToString();

                //cbxCategory.SelectedIndex = 0;
                tbxAmount.Text         = "0";
                tbxAmount.BackColor    = Color.Black;
                tbxDescription.Text    = "";
                btnSaveExp.Enabled     = false;
                tbxDescription.Enabled = false;
                tbxAmount.Enabled      = false;
            }
            else
            {
                DataObjectsInitializer.checkDatabaseConnection();
                DataRow IDRow = DatabaseConnectionObject.datasetObject_Global.Tables["TableIDNumbers"].Rows.Find("TabExp");
                lblExpID.Text = IDRow["Table Prefix"].ToString() + IDRow["Next ID Number"].ToString();

                //cbxCategory.SelectedIndex = 0;
                tbxAmount.Text         = "0";
                tbxAmount.BackColor    = Color.Black;
                tbxDescription.Text    = "";
                btnSaveExp.Enabled     = false;
                tbxDescription.Enabled = true;
                tbxAmount.Enabled      = true;
            }
        }
コード例 #2
0
        private void btnSaveExp_Click(object sender, EventArgs e)
        {
            OleDbTransaction oledbTrans = null;

            try
            {
                oledbTrans = DatabaseConnectionObject.connectionObj_Global.BeginTransaction();

                Dictionary <String, Object> Dic2Use = new Dictionary <string, object> {
                };
                Dic2Use.Add("ExpenseID", lblExpID.Text);
                Dic2Use.Add("UserID", GlobalVariables.CurrentSessionID);
                Dic2Use.Add("Date", dtPickerExpense.Value.ToLocalTime().ToString());
                Dic2Use.Add("Expense Category", cbxCategory.SelectedItem.ToString());
                Dic2Use.Add("Description", tbxDescription.Text);
                Dic2Use.Add("Amount", tbxAmount.Text);

                new DataTableManager("Expenses", DatabaseConnectionObject.datasetObject_Global, oledbTrans, GlobalVariables.CurrentSessionID).CreateRow(Dic2Use, Dic2Use["ExpenseID"].ToString());

                Dic2Use.Clear();

                String NextIDNmber = DatabaseConnectionObject.datasetObject_Global.Tables["TableIDNumbers"].Rows.Find("TabExp")["Next ID Number"].ToString();
                NextIDNmber = (long.Parse(NextIDNmber) + 1).ToString();


                Dic2Use.Clear();
                Dic2Use.Add("Next ID Number", NextIDNmber);

                new DataTableManager("TableIDNumbers", DatabaseConnectionObject.datasetObject_Global, oledbTrans, GlobalVariables.CurrentSessionID).EditRow("TabExp", Dic2Use);


                oledbTrans.Commit();

                MessageBox.Show(lblExpID.Text + " Expense Sucessfully saved", "Sucess");

                DataObjectsInitializer.checkDatabaseConnection();
                DataRow IDRow = DatabaseConnectionObject.datasetObject_Global.Tables["TableIDNumbers"].Rows.Find("TabExp");
                lblExpID.Text = IDRow["Table Prefix"].ToString() + IDRow["Next ID Number"].ToString();

                cbxCategory.SelectedIndex = 0;
                tbxAmount.Text            = "0";
                tbxDescription.Text       = "";
                btnSaveExp.Enabled        = false;
            }
            catch (Exception ex) {
                if (oledbTrans != null)
                {
                    oledbTrans.Rollback();
                }

                MessageBox.Show("Reason: " + ex.Message.ToString(), "Error Saving Expenses");
            }
        }
コード例 #3
0
        private void BackupAndRestore_Load(object sender, EventArgs e)
        {
            try
            {
                DataObjectsInitializer.checkDatabaseConnection();
                lblCurrBackpSession.Text = "Current Session ID: " + GlobalVariables.CurrentSessionID;
                lblTotalEntries.Text     = "Total Backup Rows: " + DatabaseConnectionObject.datasetObject_Global.Tables["BackupSessions"].Rows.Count.ToString();

                if (DatabaseConnectionObject.datasetObject_Global.Tables["BackupSessions"].Rows.Count == 0)
                {
                    btnBackup.Enabled = false;
                }
            }
            catch (Exception ex) {
                MessageBox.Show("Reason: " + ex.Message.ToString(), "Error Initalising Backup");
                this.Close();
            }
        }
コード例 #4
0
        private void ManageExpenses_Load(object sender, EventArgs e)
        {
            try{
                DataObjectsInitializer.checkDatabaseConnection();
                DataRow IDRow = DatabaseConnectionObject.datasetObject_Global.Tables["TableIDNumbers"].Rows.Find("TabExp");
                lblExpID.Text = IDRow["Table Prefix"].ToString() + IDRow["Next ID Number"].ToString();

                cbxCategory.SelectedIndex = 0;
                tbxAmount.Text            = "0";
                tbxAmount.BackColor       = Color.Black;
                tbxDescription.Text       = "";
                btnSaveExp.Enabled        = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Reason: " + ex.Message.ToString(), "Error Initalising Expense Module");
                this.Close();
            }
        }