private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { if (givingTypesDataGridView.Rows.Count == 0) { return; } int id = Convert.ToInt32(givingTypesDataGridView.SelectedRows[0].Cells["givingTypeId"].Value); GivingTypesController givingTypesController = new GivingTypesController(); GivingType givingType = givingTypesController.Show(id); DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete Oferring Type: " + 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) { givingType.Delete(); MessageBox.Show("Offering Type Deleted from records!", "Offering Type Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadGivingTypes(); } }
void LoadControls() { //Load offering type GivingTypesController gtc = new GivingTypesController(); givingTypes = gtc.ShowAll(); if (givingTypes.Count > 0) { Dictionary <int, string> givingTypesLibrary = new Dictionary <int, string>(); givingTypesLibrary.Add(0, "<All>"); foreach (GivingType givingType in givingTypes) { givingTypesLibrary.Add(givingType.id, givingType.title); } givingTypesCmbBx.DataSource = new BindingSource(givingTypesLibrary, null); givingTypesCmbBx.DisplayMember = "Value"; givingTypesCmbBx.ValueMember = "Key"; givingTypesCmbBx.SelectedIndex = 0; } else { MessageBox.Show("No offering types available! no registered offering type found.", "Offering Not Available", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } //initialize Controls periodCmbBx.SelectedIndex = 0; }
public void LoadGivingTypes() { GivingTypesController givingTypesController = new GivingTypesController(); givingTypes = givingTypesController.ShowAll(); givingTypesDataGridView.Rows.Clear(); givingTypesDataGridView.Columns.Clear(); givingTypesDataGridView.Refresh(); //setup //columns givingTypesDataGridView.Columns.Add("givingTypeId", "ID"); givingTypesDataGridView.Columns.Add("title", "Title"); givingTypesDataGridView.Columns.Add("isRegular", "Regular Offering Type"); givingTypesDataGridView.Columns.Add("isActive", "Active"); givingTypesDataGridView.Columns["givingTypeId"].Visible = false; //rows if (givingTypes.Count > 0) { foreach (GivingType givingType in givingTypes) { givingTypesDataGridView.Rows.Add( givingType.id, givingType.title, (givingType.isRegular ? "Yes" : "No"), (givingType.isActive ? "Yes" : "No")); } } else { MessageBox.Show("No offering type are currently registered in the system. Please add an offering type!", "No Offering Type Found!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } }
public GivingItem(DataRow r) { GivingsController gc = new GivingsController(); GivingTypesController gtc = new GivingTypesController(); this.id = Convert.ToInt32(r["givingItemId"]); this.giving = gc.Show(Convert.ToInt32(r["givingId"])); this.givingType = gtc.Show(Convert.ToInt32(r["givingTypeId"])); this.amount = Convert.ToDouble(r["amount"]); this.note = r["note"].ToString(); }
public void Update(string title, bool isRegular, bool isActive) { GivingTypesController givingTypesController = new GivingTypesController(); givingTypesController.Update(this.id, new Param("title", title), new Param("isRegular", isRegular), new Param("isActive", isActive)); this.title = title; this.isRegular = isRegular; this.isActive = isActive; }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { if (givingTypesDataGridView.Rows.Count == 0) { return; } int id = Convert.ToInt32(givingTypesDataGridView.SelectedRows[0].Cells["givingTypeId"].Value); GivingTypesController givingTypesController = new GivingTypesController(); GivingType givingType = givingTypesController.Show(id); AddUpdateGivingTypeFrm editGivingType = new AddUpdateGivingTypeFrm(true, givingType); editGivingType.FormClosing += new FormClosingEventHandler(this.GivingTypeUpdated); editGivingType.ShowDialog(); }
public GivingType(string title, bool isRegular, bool isActive) { GivingTypesController gtc = new GivingTypesController(); gtc.Add( new Param("title", title), new Param("isRegular", isRegular), new Param("isActive", isActive)); GivingType gt = gtc.GetLastAdded(); this.id = gt.id; this.title = gt.title; this.isRegular = gt.isRegular; this.isActive = gt.isActive; }
public override void Add(params Param[] @params) { if (@params.Length != 4) { return; } GivingsController gc = new GivingsController(); GivingTypesController gtc = new GivingTypesController(); if (gc.Show((int)@params[0].value) == null || gtc.Show((int)@params[1].value) == null) { MessageBox.Show("Offering or Offering Type not found!", "Offering Item Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } base.Add(@params); }
void LoadItems() { List <GivingType> givingTypes = new List <GivingType>(); GivingTypesController gtc = new GivingTypesController(); givingTypes = isUpdate? gtc.ShowUnusedExcept(giving, givingItem.givingType):gtc.ShowUnused(giving); if (givingTypes.Count > 0) { Dictionary <int, string> givingTypesLibrary = new Dictionary <int, string>(); foreach (GivingType givingType in givingTypes) { givingTypesLibrary.Add(givingType.id, givingType.title); } givingTypesCmbBx.DataSource = new BindingSource(givingTypesLibrary, null); givingTypesCmbBx.DisplayMember = "Value"; givingTypesCmbBx.ValueMember = "Key"; if (isUpdate) { givingTypesCmbBx.SelectedValue = givingItem.givingType.id; } else { givingTypesCmbBx.SelectedIndex = 0; } } else { MessageBox.Show("No offering types available! All offering types have been already used or no registered offering type found.", "Offering Not Available", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } if (isUpdate) { amountTxt.Text = givingItem.amount.ToString(); noteTxt.Text = givingItem.note; } }
public void Delete() { GivingTypesController givingTypesController = new GivingTypesController(); givingTypesController.Delete(this.id); }