Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 4
0
        private void btnDelete_Click_1(object sender, EventArgs e)
        {
            OleDbTransaction transactionObj = null;

            try
            {
                DialogResult result = MessageBox.Show("Are You Sure you Want to Delete " + lstBxItmID.SelectedItem.ToString() + " ?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

                if (result == System.Windows.Forms.DialogResult.No)
                {
                }
                else if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    transactionObj = DatabaseConnectionObject.connectionObj_Global.BeginTransaction();

                    DataObjectsInitializer ItemsTableObj   = new DataObjectsInitializer("Items", DatabaseConnectionObject.datasetObject_Global, transactionObj);
                    DataObjectsInitializer TableIDTableObj = new DataObjectsInitializer("TableIDNumbers", DatabaseConnectionObject.datasetObject_Global, transactionObj);


                    //DataRow Row2Delete = DatabaseConnectionObject.datasetObject_Global.Tables["Items"].Rows.Find(DeleteDictionary[lstBxItmID.SelectedItem.ToString()]);

                    new DataTableManager("Items", DatabaseConnectionObject.datasetObject_Global, transactionObj, GlobalVariables.CurrentSessionID).Delete(DeleteDictionary[lstBxItmID.SelectedItem.ToString()]);

                    transactionObj.Commit();

                    MessageBox.Show("Item - " + lstBxItmID.SelectedItem.ToString() + " successfully deleted", "Success");

                    DeleteList.Remove(lstBxItmID.SelectedItem.ToString());

                    tbxItmID.Text = "";

                    btnDelete.Enabled = false;

                    lstBxItmID.DataSource = DeleteList;
                }
            }
            catch (Exception ex) {
                if (transactionObj != null)
                {
                    transactionObj.Rollback();
                }
                MessageBox.Show("Error Deleting Item : " + ex.Message.ToString(), "Error Deleting Item");
            }
        }
Ejemplo n.º 5
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();
            }
        }
        public Boolean populate_DataSet()
        {
            List <string> listOfTableNames = new List <string> {
                "Items", "DebtDetails", "Debtors", "Users", "Sales", "Purchases", "TableIDNumbers", "Units", "Settings", "SessionData", "BackUpSessions", "Expenses"
            };


            datasetObject_Global.Clear();



            foreach (string Table_Name in listOfTableNames)
            {
                DataObjectsInitializer DataObject = new DataObjectsInitializer(Table_Name, datasetObject_Global, connectionObj_Global);


                // MessageBox.Show("Dataset Now has : " + datasetObject_Global.Tables.Count.ToString() + " tables!!");
            }


            return(true);
        }
Ejemplo n.º 7
0
 public DataTableManager(String TableName, DataSet datasetObject, OleDbTransaction transacttionObj, String BackupSessionID)
 {
     dbObject        = new DataObjectsInitializer(TableName, datasetObject, transacttionObj, BackupSessionID);
     dbSessionObject = new DataObjectsInitializer("BackUpSessions", datasetObject, transacttionObj, BackupSessionID);
     TableNam        = TableName;
 }