private void button2_Click(object sender, EventArgs e) { PatrimoniMes patMes = (PatrimoniMes)binding.AddNew(); patMes.Data = dataDateTimePicker.Value.Date; patMes.Tipus = tipusTextBox.Text; patMes.Valor = decimal.Parse(valorTextBox.Text); this.Close(); }
private void button7_Click(object sender, EventArgs e) { var selectedCells = this.dataGridView2.SelectedCells; if (selectedCells.Count == 1) { var cell = selectedCells[0]; PatrimoniMes reg = compte.patrimoniMes[cell.RowIndex]; DialogResult dialogResult = MessageBox.Show("Segur que vols eliminar aquest patrimoni mes?\n\n", "Elimina patrimoni", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { compte.patrimoniMes.Remove(reg); this.dataGridView2.Refresh(); } } }
private void dataGridView2_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { // Pijama per mes if (compte != null && compte.patrimoniMes != null) { if (e.RowIndex < compte.patrimoniMes.Count) { PatrimoniMes patMes = compte.patrimoniMes[e.RowIndex]; if (patMes.Data.Month % 2 == 1) { e.CellStyle.BackColor = Color.FromArgb(184, 204, 228); } else { e.CellStyle.BackColor = Color.FromArgb(220, 230, 241); } } } }