Exemplo n.º 1
0
        protected void dgCashPaymentDetail_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "AddNew")
            {
                try
                {
                    CashPaymentRequestDetail cprd = new CashPaymentRequestDetail();
                    cprd.CashPaymentRequest = _presenter.CurrentCashPaymentRequest;
                    TextBox txtAmount = e.Item.FindControl("txtAmount") as TextBox;
                    cprd.Amount = Convert.ToDecimal(txtAmount.Text);
                    TextBox txtAccountCode = e.Item.FindControl("txtAccountCode") as TextBox;
                    cprd.AccountCode = txtAccountCode.Text;
                    DropDownList ddlAccountDescription = e.Item.FindControl("ddlAccountDescription") as DropDownList;
                    cprd.ItemAccount = _presenter.GetItemAccount(Convert.ToInt32(ddlAccountDescription.SelectedValue));
                    DropDownList ddlProject = e.Item.FindControl("ddlProject") as DropDownList;
                    cprd.Project = _presenter.GetProject(Convert.ToInt32(ddlProject.SelectedValue));
                    DropDownList ddlGrant = e.Item.FindControl("ddlGrant") as DropDownList;
                    cprd.Grant = _presenter.GetGrant(int.Parse(ddlGrant.SelectedValue));
                    _presenter.CurrentCashPaymentRequest.TotalAmount += cprd.Amount;
                    if (ddlAmountType.SelectedValue == "Actual Amount")
                    {
                        cprd.ActualExpendture = Convert.ToDecimal(txtAmount.Text);
                    }
                    _presenter.CurrentCashPaymentRequest.CashPaymentRequestDetails.Add(cprd);

                    dgCashPaymentDetail.EditItemIndex = -1;
                    BindCashPaymentDetails();
                    Master.ShowMessage(new AppMessage("Payment Detail Successfully Added", Chai.WorkflowManagment.Enums.RMessageType.Info));
                }
                catch (Exception ex)
                {
                    Master.ShowMessage(new AppMessage("Error: Unable to Save Payment " + ex.Message, Chai.WorkflowManagment.Enums.RMessageType.Error));
                }
            }
        }
Exemplo n.º 2
0
        protected void dgCashPaymentDetail_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            if (e.CommandName == "AddNew")
            {
                try
                {
                    CashPaymentRequestDetail cprd = new CashPaymentRequestDetail();
                    cprd.CashPaymentRequest = _presenter.CurrentCashPaymentRequest;
                    TextBox txtAmount = e.Item.FindControl("txtAmount") as TextBox;
                    cprd.Amount = Convert.ToDecimal(txtAmount.Text);
                    TextBox txtAccountCode = e.Item.FindControl("txtAccountCode") as TextBox;
                    cprd.AccountCode = txtAccountCode.Text;
                    DropDownList ddlAccountDescription = e.Item.FindControl("ddlAccountDescription") as DropDownList;
                    cprd.ItemAccount = _presenter.GetItemAccount(Convert.ToInt32(ddlAccountDescription.SelectedValue));
                    DropDownList ddlProject = e.Item.FindControl("ddlProject") as DropDownList;
                    cprd.Project = _presenter.GetProject(Convert.ToInt32(ddlProject.SelectedValue));
                    DropDownList ddlGrant = e.Item.FindControl("ddlGrant") as DropDownList;
                    cprd.Grant = _presenter.GetGrant(int.Parse(ddlGrant.SelectedValue));
                    CheckBox ckSupDocAttached = e.Item.FindControl("ckSupDocAttached") as CheckBox;
                    cprd.SupportDocAttached = ckSupDocAttached.Checked;
                    _presenter.CurrentCashPaymentRequest.TotalAmount += cprd.Amount;
                    if (ddlAmountType.SelectedValue == "Actual Amount")
                    {
                        cprd.ActualExpendture = Convert.ToDecimal(txtAmount.Text);
                    }
                    //Add Checklists for attachments if available
                    foreach (ItemAccountChecklist checklist in cprd.ItemAccount.ItemAccountChecklists)
                    {
                        CPRAttachment attachment = new CPRAttachment();
                        attachment.CashPaymentRequestDetail = _presenter.CurrentCashPaymentRequest.GetDetailByItemAccount(cprd.ItemAccount.Id);
                        attachment.ItemAccountChecklists.Add(checklist);
                        cprd.CPRAttachments.Add(attachment);
                    }
                    _presenter.CurrentCashPaymentRequest.CashPaymentRequestDetails.Add(cprd);
                    if (ddlAmountType.SelectedValue != "Advanced")
                    {
                        BindAttachments();
                    }

                    dgCashPaymentDetail.EditItemIndex = -1;
                    BindCashPaymentDetails();

                    foreach (CPRAttachment attachment in _presenter.CurrentCashPaymentRequest.CashPaymentRequestDetails[e.Item.ItemIndex + 1].CPRAttachments)
                    {
                        attachment.CashPaymentRequestDetail = _presenter.CurrentCashPaymentRequest.GetCashPaymentRequestDetail((int)dgCashPaymentDetail.DataKeys[e.Item.ItemIndex + 1]);
                    }

                    Master.ShowMessage(new AppMessage("Payment Detail Successfully Added", RMessageType.Info));
                }
                catch (Exception ex)
                {
                    Master.ShowMessage(new AppMessage("Error: Unable to Save Payment Detail" + ex.Message, RMessageType.Error));
                    ExceptionUtility.LogException(ex, ex.Source);
                    ExceptionUtility.NotifySystemOps(ex, _presenter.CurrentUser().FullName);
                }
            }
        }
Exemplo n.º 3
0
 public void DeleteCashPaymentRequestDetail(CashPaymentRequestDetail CashPaymentRequestDetail)
 {
     _controller.DeleteEntity(CashPaymentRequestDetail);
 }