Ejemplo n.º 1
0
        private void toolStripButton2_Click_1(object sender, EventArgs e)
        {
            NewExpense frm = new NewExpense(null);

            frm.MdiParent = MainForm.ActiveForm;
            frm.Show();
            this.Close();
        }
Ejemplo n.º 2
0
        private void dtGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;

            if (e.ColumnIndex == dtGrid.Columns[1].Index && e.RowIndex >= 0)
            {
                if (fileIDs.Contains(dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString()))
                {
                    fileIDs.Remove(dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString());
                    Console.WriteLine("REMOVED this id " + dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString());
                }
                else
                {
                    fileIDs.Add(dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString());
                    Console.WriteLine("ADDED ITEM " + dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString());
                }
            }
            if (e.ColumnIndex == dtGrid.Columns[16].Index && e.RowIndex >= 0)
            {
                NewExpense frm = new NewExpense(dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString());
                frm.MdiParent = MainForm.ActiveForm;
                frm.Show();
                this.Close();
            }
            try
            {
                if (e.ColumnIndex == dtGrid.Columns[17].Index && e.RowIndex >= 0)
                {
                    if (MessageBox.Show("YES or NO?", "Are you sure you want to delete this expense? ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                    {
                        string Query = "DELETE from expenses WHERE expenseID ='" + dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString() + "'";
                        Helper.Execute(Query, DBConnect.conn);
                        string Query2 = "INSERT INTO `deletion`( `table`, `eid`,`column`, `created`) VALUES ('expenses','" + dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString() + "','expenseID','" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "');";
                        Helper.Execute(Query2, DBConnect.conn);
                        MessageBox.Show("Information deleted");
                    }
                    Console.WriteLine("DELETE on row {0} clicked", e.RowIndex + dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString() + dtGrid.Rows[e.RowIndex].Cells[2].Value.ToString());
                }
            }
            catch { }
        }