Example #1
0
        protected void ctlRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string filter = string.Empty;

            //ExpenseDataSet expDs = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId);
            //ExpenseDataSet.FnExpenseInvoiceRow row = expDs.FnExpenseInvoice.FindByInvoiceID(UIHelper.ParseLong(e.CommandArgument.ToString()));
            if (e.CommandName.Equals("EditInovice"))
            {
                PopupCaller popupEdit = (PopupCaller)e.Item.FindControl("ctlEditPopupCaller");
                if (ExpenseDocumentEditor.NotifyUpdateExpense())
                {
                    ShowPopup(popupEdit.PopupScript);
                }
            }
            else if (e.CommandName.Equals("DeleteInvoice"))
            {
                ExpenseDataSet expDs     = (ExpenseDataSet)TransactionService.GetDS(this.TransactionId);
                long           invoiceID = UIHelper.ParseLong(e.CommandArgument.ToString());
                ExpenseDataSet.FnExpenseInvoiceRow[] invoice = (ExpenseDataSet.FnExpenseInvoiceRow[])expDs.FnExpenseInvoice.Select(string.Format("InvoiceID  = {0}", e.CommandArgument.ToString()));
                if (invoice.Count() > 0)
                {
                    string invoiceType = invoice[0].InvoiceDocumentType;
                    FnExpenseInvoiceService.DeleteInvoiceOnTransaction(invoiceID, this.TransactionId);
                    if (invoiceType.Equals(InvoiceType.General))
                    {
                        string URL = ShowExpenseGeneral(invoiceID);
                        ctlInvoicePopupCaller.URL = URL.Replace("[mode]", FlagEnum.NewFlag);
                    }
                    else if (invoiceType.Equals(InvoiceType.Perdiem))
                    {
                        string URL = ShowPerdiemPopup(FlagEnum.NewFlag, null);
                        ctlPerdiemPopupCaller.URL = URL;
                    }
                }

                BindExpenseGrid();
                ExpenseDocumentEditor.NotifyPaymentDetailChange();
            }
            else if (e.CommandName.Equals("ViewInvoice"))
            {
                PopupCaller popupView = (PopupCaller)e.Item.FindControl("ctlViewPopupCaller");
                ShowPopup(popupView.PopupScript);
            }
        }
Example #2
0
        protected void ctlRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            string url = string.Empty;

            if (e.Item.DataItem != null)
            {
                ExpenseDataSet expDs = (ExpenseDataSet)TransactionService.GetDS(TransactionId);
                ExpenseDataSet.FnExpenseInvoiceRow  invoice            = (ExpenseDataSet.FnExpenseInvoiceRow)e.Item.DataItem;
                ExpenseDataSet.FnExpenseDocumentRow expenseDocumentRow = expDs.FnExpenseDocument.FindByExpenseID(this.ExpDocumentID);

                PopupCaller popupEdit       = (PopupCaller)e.Item.FindControl("ctlEditPopupCaller");
                PopupCaller popupView       = (PopupCaller)e.Item.FindControl("ctlViewPopupCaller");
                LinkButton  edit            = (LinkButton)e.Item.FindControl("ctlEdit");
                LinkButton  delete          = (LinkButton)e.Item.FindControl("ctlDelete");
                LinkButton  view            = (LinkButton)e.Item.FindControl("ctlView");
                Literal     totalBaseAmount = (Literal)e.Item.FindControl("ctlTotalAmount");
                Literal     totalNetAmount  = (Literal)e.Item.FindControl("ctlNetAmount");

                if (IsRepOffice)
                {
                    totalBaseAmount.Text = UIHelper.BindDecimal(invoice.TotalBaseAmountLocalCurrency.ToString());
                    totalNetAmount.Text  = UIHelper.BindDecimal(invoice.NetAmountLocalCurrency.ToString());
                }
                else
                {
                    totalBaseAmount.Text = UIHelper.BindDecimal(invoice.TotalBaseAmount.ToString());
                    totalNetAmount.Text  = UIHelper.BindDecimal(invoice.NetAmount.ToString());
                }

                if (!invoice.IsInvoiceDocumentTypeNull() && invoice.InvoiceDocumentType.Equals(InvoiceType.Perdiem))
                {
                    popupEdit.URL = ShowPerdiemPopup(FlagEnum.EditFlag, invoice.InvoiceID);
                    popupView.URL = ShowPerdiemPopup(FlagEnum.ViewFlag, invoice.InvoiceID);
                }
                if (!invoice.IsInvoiceDocumentTypeNull() && invoice.InvoiceDocumentType.Equals(InvoiceType.General))
                {
                    url           = ShowExpenseGeneral(invoice.InvoiceID);
                    popupEdit.URL = url.Replace("[mode]", FlagEnum.EditFlag);
                    popupView.URL = url.Replace("[mode]", FlagEnum.ViewFlag);
                }

                // Show Mileage.
                if (!invoice.IsInvoiceDocumentTypeNull() && invoice.InvoiceDocumentType.Equals(InvoiceType.Mileage))
                {
                    popupEdit.URL = ShowMileagePopup(FlagEnum.EditFlag);
                    popupView.URL = ShowMileagePopup(FlagEnum.ViewFlag);
                }

                SS.Standard.WorkFlow.DTO.WorkFlow workflow = SS.Standard.WorkFlow.Query.WorkFlowQueryProvider.WorkFlowQuery.GetWorkFlowByDocumentID(this.DocumentID);

                if (InitialFlag.Equals(FlagEnum.ViewFlag))
                {
                    edit.Visible   = false;
                    delete.Visible = false;
                    view.Visible   = true;
                }
                else
                {
                    edit.Visible = true;
                    view.Visible = false;

                    if (!invoice.IsInvoiceDocumentTypeNull() && invoice.InvoiceDocumentType.Equals(InvoiceType.Mileage))
                    {
                        delete.Visible = false;
                    }
                    else
                    if (workflow != null && workflow.CurrentState.Name.Equals(WorkFlowStateFlag.Hold))
                    {
                        delete.Visible = false;
                    }
                    else
                    {
                        delete.Visible = true;
                    }
                }

                Literal seq = (Literal)e.Item.FindControl("ctlSeq");

                seq.Text += e.Item.ItemIndex + 1;

                BaseGridView gridview = (BaseGridView)e.Item.FindControl("ctlInvoiceItem");

                string filter = String.Format("InvoiceID = {0}", invoice.InvoiceID);
                gridview.DataSource = expDs.FnExpenseInvoiceItem.Select(filter);
                gridview.DataBind();
            }
        }