Esempio n. 1
0
        protected void RadGridStudentList_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            var btnNewProgram        = RadToolBarStudentContract.FindItemByText("New Program");
            var btnNewPackageProgram = RadToolBarStudentContract.FindItemByText("New Package");
            var btnNewManualInvoice  = RadToolBarStudentContract.FindItemByText("New Manual Invoice");
            var btnNewHomesaty       = RadToolBarStudentContract.FindItemByText("New Homestay");
            var btnNewDormitory      = RadToolBarStudentContract.FindItemByText("New Dormitory");

            if (RadGridStudentList.SelectedValue == null)
            {
                btnNewProgram.Enabled        = false;
                btnNewPackageProgram.Enabled = false;
                btnNewManualInvoice.Enabled  = false;
                btnNewHomesaty.Enabled       = false;
                btnNewDormitory.Enabled      = false;
            }
            else
            {
                btnNewProgram.Enabled        = true;
                btnNewPackageProgram.Enabled = true;
                btnNewManualInvoice.Enabled  = true;
                btnNewHomesaty.Enabled       = true;
                btnNewDormitory.Enabled      = true;
            }

            GetStudent();
            GetStudentContract();
        }
Esempio n. 2
0
        protected void RadGridStudentContract_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            if (RadGridStudentContract.SelectedValue != null)
            {
                CStudent student         = new CStudent();
                var      studentContract = student.GetVwStudentContract(Convert.ToInt32(RadGridStudentContract.SelectedValue));
                if (studentContract != null)
                {
                    var btnRefund         = RadToolBarStudentContract.FindItemByText("Refund");
                    var btnTransfer       = RadToolBarStudentContract.FindItemByText("Transfer");
                    var btnCancel         = RadToolBarStudentContract.FindItemByText("Cancel");
                    var btnBreak          = RadToolBarStudentContract.FindItemByText("Break");
                    var btnScheduleChange = RadToolBarStudentContract.FindItemByText("Schedule Change");
                    var btnProgramChange  = RadToolBarStudentContract.FindItemByText("Program Change");

                    // init
                    btnRefund.Enabled         = false;
                    btnTransfer.Enabled       = false;
                    btnCancel.Enabled         = false;
                    btnBreak.Enabled          = false;
                    btnScheduleChange.Enabled = false;
                    btnProgramChange.Enabled  = false;

                    var balance = studentContract.Balance;

                    var paymentCnt        = studentContract.PaymentCnt;
                    var depositConfirmCnt = studentContract.DepositConfirmCnt;

                    var invoiceStatus = studentContract.Status;
                    var invoiceType   = studentContract.InvoiceTypeInt;
                    var invoiceId     = studentContract.InvoiceId;

                    var startDate = studentContract.StartDate;
                    var today     = DateTime.Now;

                    // =======================
                    // Refund
                    // =======================
                    // Full Paid
                    if (balance >= 0 && paymentCnt > 0 && paymentCnt == depositConfirmCnt && invoiceStatus == (int)CConstValue.InvoiceStatus.Invoiced)
                    {
                        switch (invoiceType)
                        {
                        case (int)CConstValue.InvoiceType.Simple:
                        case (int)CConstValue.InvoiceType.General:
                        case (int)CConstValue.InvoiceType.Manual:
                        case (int)CConstValue.InvoiceType.Dormitory:
                        case (int)CConstValue.InvoiceType.Homestay:
                            btnRefund.Enabled = true;
                            break;
                        }
                    }

                    // =======================
                    // Cancel
                    // =======================
                    // Before Program Start
                    if (startDate > today)
                    {
                        switch (invoiceType)
                        {
                        case (int)CConstValue.InvoiceType.Simple:
                        case (int)CConstValue.InvoiceType.General:
                        case (int)CConstValue.InvoiceType.Manual:
                        case (int)CConstValue.InvoiceType.Dormitory:
                        case (int)CConstValue.InvoiceType.Homestay:

                            if (invoiceStatus == (int)CConstValue.InvoiceStatus.Pending)
                            {
                                btnCancel.Enabled = true;
                            }
                            else if (invoiceStatus == (int)CConstValue.InvoiceStatus.Invoiced)
                            {
                                if (new CPayment().InvoiceCheck(invoiceId) == 0)
                                {
                                    btnCancel.Enabled = true;
                                }
                            }
                            break;
                        }
                    }

                    // =======================
                    // Break
                    // =======================
                    // After Program Start
                    if (startDate <= today)
                    {
                        switch (invoiceType)
                        {
                        case (int)CConstValue.InvoiceType.Simple:
                        case (int)CConstValue.InvoiceType.General:
                        case (int)CConstValue.InvoiceType.Manual:
                            btnBreak.Enabled = true;
                            break;
                        }
                    }

                    // =======================
                    // Schedule change
                    // =======================
                    // Before Program Start
                    if (startDate > today)
                    {
                        switch (invoiceType)
                        {
                        case (int)CConstValue.InvoiceType.Simple:
                        case (int)CConstValue.InvoiceType.General:
                        case (int)CConstValue.InvoiceType.Manual:
                        case (int)CConstValue.InvoiceType.Dormitory:
                        case (int)CConstValue.InvoiceType.Homestay:
                            if (invoiceStatus == (int)CConstValue.InvoiceStatus.Pending || invoiceStatus == (int)CConstValue.InvoiceStatus.Invoiced)
                            {
                                btnScheduleChange.Enabled = true;
                            }
                            break;
                        }
                    }

                    // =======================
                    // Program Change
                    // =======================
                    // nothing

                    // =======================
                    // Transfer
                    // =======================
                    // nothing
                }
            }
        }