public List <GivingItem> givingItems() { List <GivingItem> gi = new List <GivingItem>(); GivingItemsController gic = new GivingItemsController(); gi = gic.ShowAll(new Param("givingId", id)); return(gi); }
public void Update(Giving giving, GivingType givingType, double amount, string note = "") { GivingItemsController gic = new GivingItemsController(); gic.Update(this.id, new Param("givingId", giving.id), new Param("givingTypeId", givingType.id), new Param("amount", amount), new Param("note", note)); this.giving = giving; this.givingType = givingType; this.amount = amount; this.note = note; }
public GivingItem(Giving giving, GivingType givingType, double amount, string note = "") { GivingItemsController gc = new GivingItemsController(); gc.Add( new Param("givingId", giving.id), new Param("givingTypeId", givingType.id), new Param("amount", amount), new Param("note", note) ); GivingItem gi = gc.GetLastAdded(); this.id = gi.id; this.giving = gi.giving; this.givingType = gi.givingType; this.amount = gi.amount; this.note = gi.note; }
private void UpdateGivingItemBtn_Click(object sender, EventArgs e) { if (givingItemsDataGridView.Rows.Count == 0) { return; } GivingItemsController gic = new GivingItemsController(); GivingItem gi = gic.Show(Convert.ToInt32(givingItemsDataGridView.SelectedRows[0].Cells["givingItemId"].Value)); if (gi == null) { MessageBox.Show("Failed to get giving item", "Error Occured", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AddUpdateGivingItemFrm editGivingItemFrm = new AddUpdateGivingItemFrm(true, selectedGiving, gi); editGivingItemFrm.FormClosing += new FormClosingEventHandler(delegate { this.LoadGivingItems(selectedGiving); }); editGivingItemFrm.ShowDialog(); }
private void DeleteGivingItemBtn_Click(object sender, EventArgs e) { if (givingItemsDataGridView.Rows.Count == 0) { return; } GivingItemsController gic = new GivingItemsController(); GivingItem g = gic.Show((int)givingItemsDataGridView.SelectedRows[0].Cells["givingItemId"].Value); DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete Oferring Item: " + g.givingType.title + "\n NOTE: this action cannot be undone!", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (dialogResult == DialogResult.No) { return; } else if (dialogResult == DialogResult.Yes) { g.Delete(); MessageBox.Show("Offering item Deleted from records!", "Offering Item Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadGivingItems(selectedGiving); } }
void LoadGraph() { if (dateRangeCmbBx.SelectedValue == null) { return; } if (dateRangeCmbBx.Items.Count == 0) { return; } DateTime selectedDate; if (!DateTime.TryParse(dateRangeCmbBx.SelectedValue.ToString(), out selectedDate)) { selectedDate = ((KeyValuePair <DateTime, string>)dateRangeCmbBx.SelectedValue).Key; } int selectedGivingType = givingTypesCmbBx.SelectedIndex == 0 ? 0 : (int)givingTypesCmbBx.SelectedValue; int selectedYear = selectedDate.Year; int selectedMonth = periodCmbBx.SelectedIndex == 0 ? 0 : selectedDate.Month; //loading the graph displayChart.Series.Clear(); double total = 0; if (selectedGivingType == 0) { for (int i = 0; i < givingTypes.Count; i++) { DataTable dt = new GivingItemsController().ShowAll(selectedYear, selectedMonth, givingTypes[i].id); Series s = new Series(givingTypes[i].title); s.ChartType = SeriesChartType.SplineArea; foreach (DataRow r in dt.Rows) { total += Convert.ToDouble(r["total"]); string displayStr = (periodCmbBx.SelectedIndex == 0 ? CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(Convert.ToInt32(r["month"])) + " " + r["year"].ToString() : Convert.ToDateTime(r["start"]).ToString("MMM dd, yyyy") + " - " + Convert.ToDateTime(r["end"]).ToString("MMM dd, yyyy")); s.Points.AddXY(displayStr, r["total"]); // Console.WriteLine(r["total"].ToString()); } displayChart.Series.Add(s); displayChart.AlignDataPointsByAxisLabel(); } } else { DataTable dt = new GivingItemsController().ShowAll(selectedYear, selectedMonth, selectedGivingType); displayChart.Series.Add(new GivingTypesController().Show(selectedGivingType).title); displayChart.Series[0].ChartType = SeriesChartType.SplineRange; foreach (DataRow r in dt.Rows) { total += Convert.ToDouble(r["total"]); string displayStr = (periodCmbBx.SelectedIndex == 0 ? CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(Convert.ToInt32(r["month"])) + " " + r["year"].ToString() : Convert.ToDateTime(r["start"]).ToString("MMM dd, yyyy") + " - " + Convert.ToDateTime(r["end"]).ToString("MMM dd, yyyy")); displayChart.Series[0].Points.AddXY(displayStr, r["total"]); // Console.WriteLine(r["total"].ToString()); } } totalTxt.Text = total.ToString(); }
public void Delete() { GivingItemsController gic = new GivingItemsController(); gic.Delete(this.id); }