public void GetCreditMemoPayoutInfo() { // toolbar foreach (RadToolBarItem toolbarItem in RadToolBarCreditMemo.Items) { if (toolbarItem.Text == "Disbursement") { if (RadGridCreditMemo.SelectedValue != null) { var creditMemo = new CCreditMemo().GetVwCreditMemo(Convert.ToInt32(RadGridCreditMemo.SelectedValue)); if (creditMemo != null) { var cCreditMemoPayout = new CCreditMemoPayout(); var creditMemoPayoutList = cCreditMemoPayout.GetCreditMemoPayoutList(creditMemo.CreditMemoId); bool hasNullOfDisbursement = false; foreach (var c in creditMemoPayoutList) { if (c.Disbursement == false && c.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved) { toolbarItem.Enabled = true; hasNullOfDisbursement = true; break; } } if (hasNullOfDisbursement == false) { toolbarItem.Enabled = false; } } else { toolbarItem.Enabled = false; } } else { toolbarItem.Enabled = false; } } else { if (toolbarItem.Text == "View Invoice" || toolbarItem.Text == "View Payment" || toolbarItem.Text == "View Deposit" || toolbarItem.Text == "Student Page" || toolbarItem.Text == "Invoice Page" || toolbarItem.Text == "Payment Page" || toolbarItem.Text == "Deposit Page" || toolbarItem.Text == "Refund Page" || toolbarItem.Text == "Excel") { continue; } toolbarItem.Enabled = false; } } // toolbar foreach (RadToolBarItem toolbarItem in RadToolBarCreditMemoPayout.Items) { if (toolbarItem.Text == "New Payout") { if (RadGridCreditMemo.SelectedValue != null) { toolbarItem.Enabled = true; } else { toolbarItem.Enabled = false; } } } if (RadGridCreditMemoPayout.SelectedValue != null) { var cCreditMemoPayout = new CCreditMemoPayout(); var creditMemoPayout = cCreditMemoPayout.Get(Convert.ToInt32(RadGridCreditMemoPayout.SelectedValue)); CreditMemoPayout1.SetData(creditMemoPayout); // toolbar foreach (RadToolBarItem toolbarItem in RadToolBarCreditMemoPayout.Items) { // request active check if (toolbarItem.Text == "Request") { if ((creditMemoPayout.ApprovalStatus == null || creditMemoPayout.ApprovalStatus == (int)CConstValue.ApprovalStatus.Revise) && creditMemoPayout.CreatedId == CurrentUserId) { toolbarItem.Enabled = true; } else { toolbarItem.Enabled = false; } } else if (toolbarItem.Text == "Cancel") { if ((creditMemoPayout.ApprovalStatus == null || creditMemoPayout.ApprovalStatus == (int)CConstValue.ApprovalStatus.Revise || creditMemoPayout.ApprovalStatus == (int)CConstValue.ApprovalStatus.Requested) && creditMemoPayout.CreatedId == CurrentUserId) { toolbarItem.Enabled = true; } else { toolbarItem.Enabled = false; } } else if (toolbarItem.Text == "Approve" || toolbarItem.Text == "Reject" || toolbarItem.Text == "Revise") { // approve active check var refundApproveInfo = new CGlobal(); var supervisor = refundApproveInfo.CheckApprovalEnable((int)CConstValue.Approval.CreditMemoPayout, Convert.ToInt32(RadGridCreditMemoPayout.SelectedValue)); // supervisor or loy employees if ((CurrentUserId == supervisor) && creditMemoPayout.ApprovalStatus != (int)CConstValue.ApprovalStatus.Approved && creditMemoPayout.ApprovalStatus != (int)CConstValue.ApprovalStatus.Rejected && creditMemoPayout.ApprovalStatus != (int)CConstValue.ApprovalStatus.Canceled && creditMemoPayout.ApprovalStatus != null && CurrentUserId != creditMemoPayout.ApprovalId) { toolbarItem.Enabled = true; } else { toolbarItem.Enabled = false; } } } foreach (RadToolBarItem toolbarItem in RadToolBarCreditMemoPayoutHistory.Items) { if (toolbarItem.Text == "Add Payout") { if (creditMemoPayout.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved && creditMemoPayout.Disbursement && (CurrentGroupId == (int)CConstValue.UserGroupForCreditPayoutHistory.Accounting || CurrentGroupId == (int)CConstValue.UserGroupForCreditPayoutHistory.IT)) { toolbarItem.Enabled = true; } else { toolbarItem.Enabled = false; } } else if (toolbarItem.Text == "Payout Reverse") { if (CurrentGroupId == (int)CConstValue.UserGroupForCreditPayoutHistory.Accounting || CurrentGroupId == (int)CConstValue.UserGroupForCreditPayoutHistory.IT) { toolbarItem.Enabled = true; } else { toolbarItem.Enabled = false; } } } // get DownloadList FileDownloadList1.GetFileDownload(Convert.ToInt32(RadGridCreditMemoPayout.SelectedValue)); } else { foreach (RadToolBarItem toolbarItem in RadToolBarCreditMemoPayoutHistory.Items) { toolbarItem.Enabled = false; } // get DownloadList FileDownloadList1.GetFileDownload(0); } RefreshApprovalList(); }
protected void RadToolBarCreditMemo_OnButtonClick(object sender, RadToolBarEventArgs e) { if (RadGridCreditMemo.SelectedValue != null) { switch (e.Item.Text) { case "Disbursement": var cCreditMemoPayout = new CCreditMemoPayout(); var creditMemoPayoutList = cCreditMemoPayout.GetCreditMemoPayoutList(Convert.ToInt32(RadGridCreditMemo.SelectedValue)); var currentDate = DateTime.Now; foreach (var creditMemoPayout in creditMemoPayoutList) { if (creditMemoPayout.Disbursement == false && creditMemoPayout.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved) { creditMemoPayout.Disbursement = true; creditMemoPayout.DisbursementDate = currentDate; creditMemoPayout.UpdatedId = CurrentUserId; creditMemoPayout.UpdatedDate = currentDate; cCreditMemoPayout.Update(creditMemoPayout); } } RadGridCreditMemo.Rebind(); RadGridCreditMemoPayout.Rebind(); break; case "View Invoice": RunClientScript("ShowInvoiceWindow(" + RadGridCreditMemo.SelectedValues["InvoiceId"] + ");"); break; case "View Payment": RunClientScript("ShowPaymentHistoryWindow(" + RadGridCreditMemo.SelectedValues["InvoiceId"] + ");"); break; case "View Deposit": var cPayment = new CPayment(); var payment = cPayment.Get(Convert.ToInt32(RadGridCreditMemo.SelectedValues["PaymentId"])); if (payment != null) { var depositPayment = new CDepositPayment().GetByPaymentId(payment.PaymentId); if (depositPayment != null) { RunClientScript("ShowDepositPaymentWindow(" + depositPayment.DepositId + ");"); } } break; case "Student Page": Response.Redirect("~/Student?id=" + RadGridCreditMemo.SelectedValues["StudentId"]); break; case "Invoice Page": Response.Redirect("~/Invoice?id=" + RadGridCreditMemo.SelectedValues["StudentId"]); break; case "Payment Page": Response.Redirect("~/Payment?id=" + RadGridCreditMemo.SelectedValues["StudentId"]); break; case "Deposit Page": Response.Redirect("~/Deposit?id=" + RadGridCreditMemo.SelectedValues["StudentId"]); break; case "Refund Page": Response.Redirect("~/Refund?id=" + RadGridCreditMemo.SelectedValues["StudentId"]); break; } } }