protected void dgProjectGrant_UpdateCommand(object source, DataGridCommandEventArgs e) { int id = (int)dgProjectGrant.DataKeys[e.Item.ItemIndex]; ProGrant projectGrant = _Project.GetProjectGrant(id); try { DropDownList ddlFGrant = e.Item.FindControl("ddlGrant") as DropDownList; projectGrant.Grant = _presenter.GetGrant(Convert.ToInt32(ddlFGrant.SelectedValue)); TextBox txtFGrantDate = e.Item.FindControl("txtGrantDate") as TextBox; projectGrant.GrantDate = Convert.ToDateTime(txtFGrantDate.Text); _presenter.SaveOrUpdateProject(_Project); Master.ShowMessage(new AppMessage("Project Grant Updated Successfully.", ChurchERP.Enums.RMessageType.Info)); dgProjectGrant.EditItemIndex = -1; BindProjectGrants(); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Update Project Grant . " + ex.Message, ChurchERP.Enums.RMessageType.Error)); } }
protected void dgProjectGrant_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "AddNew") { try { ProGrant projectgrant = new ProGrant(); DropDownList ddlFGrant = e.Item.FindControl("ddlFGrant") as DropDownList; projectgrant.Grant = _presenter.GetGrant(Convert.ToInt32(ddlFGrant.SelectedValue)); TextBox txtFGrantDate = e.Item.FindControl("txtFGrantDate") as TextBox; projectgrant.GrantDate = Convert.ToDateTime(txtFGrantDate.Text); projectgrant.Project = _Project; _Project.ProGrants.Add(projectgrant); _presenter.SaveOrUpdateProject(_Project); Master.ShowMessage(new AppMessage("Project Grant Added Successfully.", ChurchERP.Enums.RMessageType.Info)); dgProjectGrant.EditItemIndex = -1; BindProjectGrants(); } catch (Exception ex) { Master.ShowMessage(new AppMessage("Error: Unable to Add Project Grant. " + ex.Message, ChurchERP.Enums.RMessageType.Error)); } } }
public void DeleteProjectGrant(ProGrant ProjectGrant) { _controller.DeleteEntity(ProjectGrant); }