private void toolStripButton2_Click(object sender, EventArgs e) { NewPetty frm = new NewPetty(null); frm.MdiParent = MainForm.ActiveForm; frm.Show(); this.Close(); }
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[12].Index && e.RowIndex >= 0) { NewPetty frm = new NewPetty(dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString()); frm.MdiParent = MainForm.ActiveForm; frm.Show(); this.Close(); } try { if (e.ColumnIndex == dtGrid.Columns[13].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 petty WHERE id ='" + dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString() + "'"; Helper.Execute(Query, 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()); } if (e.ColumnIndex == dtGrid.Columns[14].Index && e.RowIndex >= 0) { if (MessageBox.Show("YES or NO?", "Are you sure you want to delete this approve this petty expense? ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { string Query = "UPDATE petty SET approve ='true' WHERE id ='" + dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString() + "'"; Helper.Execute(Query, DBConnect.conn); MessageBox.Show("Information deleted"); } } if (e.ColumnIndex == dtGrid.Columns[15].Index && e.RowIndex >= 0) { if (MessageBox.Show("YES or NO?", "Update information? ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { string Query = "UPDATE petty SET paid ='true' WHERE id ='" + dtGrid.Rows[e.RowIndex].Cells[0].Value.ToString() + "'"; Helper.Execute(Query, DBConnect.conn); MessageBox.Show("Information deleted"); } } } catch { } }