Пример #1
0
    private string GetTableNameForViewType(string selectedText)
    {
        bool isApprovalList = selectedText == "My Approval" ? true : false;

        string tableName = string.Empty;

        switch (_menuId)
        {
        case (int)CConstValue.Menu.PackageProgram:
            var cPackageProgram = new CPackageProgram();
            tableName = isApprovalList ? cPackageProgram.GetTableNameForVwPackageProgramApprovalList() : cPackageProgram.GetTableNameForVwPackageProgram();
            break;

        case (int)CConstValue.Menu.CreditMemo:
            var cCreditMemo = new CCreditMemoPayout();
            tableName = isApprovalList ? cCreditMemo.GetTableNameForvwCreditMemoPayoutApprovalList() : cCreditMemo.GetTableNameForVwCreditMemoPayout();
            break;

        case (int)CConstValue.Menu.Refund:
            var cRefund = new CRefund();
            tableName = isApprovalList ? cRefund.GetTableNameForVwRefundApprovalList() : cRefund.GetTableNameForVwRefund();
            break;

        case (int)CConstValue.Menu.Scholarship:
            var cScholarship = new CScholarship();
            tableName = isApprovalList ? cScholarship.GetTableNameForVwScholarshipApprovalList() : cScholarship.GetTableNameForVwScholarship();
            break;

        case (int)CConstValue.Menu.Promotion:
            var cPromotion = new CPromotion();
            tableName = isApprovalList ? cPromotion.GetTableNameForVwPromotionApprovalList() : cPromotion.GetTableNameForVwPromotion();
            break;

        case (int)CConstValue.Menu.Agency:
            var cAgency = new CAgency();
            tableName = isApprovalList ? cAgency.GetTableNameForVwAgencyApprovalList() : cAgency.GetTableNameForVwAgency();
            break;
        }

        return(tableName);
    }
Пример #2
0
        protected void GetStudent()
        {
            if (RadGrid1.SelectedValue != null)
            {
                var cStud = new CScholarship();
                var stud  = cStud.Get(Convert.ToInt32(RadGrid1.SelectedValue));

                tbMaster.Text = stud.ScholarshipMasterNo;

                var cAgency = new CAgency();
                var agency  = cAgency.Get(Convert.ToInt32(stud.AgencyId));
                tbAgency.Text = agency.Name;

                tbAmount.Text    = stud.Amount.ToString();
                rbAmount.Checked = tbAmount.Text == string.Empty ? false : true;

                tbWeek.Text     = stud.Weeks.ToString();
                rbWeeks.Checked = tbWeek.Text == string.Empty ? false : true;

                tbComment.Text = stud.Memo;
            }

            GetSiteLocation();
        }
Пример #3
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == @"Reject" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    try
                    {
                        var type     = Convert.ToInt32(hfType.Value);
                        var id       = Convert.ToInt32(hfId.Value);
                        var idNumber = string.Empty;

                        var cApprovalHistory = new CApprovalHistory();
                        var approvalHistory  = cApprovalHistory.Get(type, id, CurrentUserId);
                        approvalHistory.ApprovalDate = DateTime.Now;
                        approvalHistory.ApprovalMemo = tbRemark.Text;
                        // Reject
                        approvalHistory.ApprovalStep = (int)CConstValue.ApprovalStatus.Rejected;

                        if (type == (int)CConstValue.Approval.Refund)
                        {
                            var cC = new CRefund();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            if (cC.Update(c))
                            {
                                var cInvoiceInfo = new CInvoice();
                                var invoiceInfo  = cInvoiceInfo.Get(c.InvoiceId);

                                var cOriginalInvoiceInfo = new CInvoice();
                                var originalInvoiceInfo  = cOriginalInvoiceInfo.Get(Convert.ToInt32(invoiceInfo.OriginalInvoiceId));

                                invoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Cancelled_RF; // Canceled_R
                                invoiceInfo.UpdatedId = CurrentUserId;

                                originalInvoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Invoiced; // Invoiced
                                originalInvoiceInfo.UpdatedId = CurrentUserId;

                                cInvoiceInfo.Update(invoiceInfo);
                                cOriginalInvoiceInfo.Update(originalInvoiceInfo);
                            }
                        }
                        // Agency
                        else if (type == (int)CConstValue.Approval.Agency)
                        {
                            var cC = new CAgency();
                            var c  = cC.Get(id);
                            idNumber         = c.AgencyNumber;
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.CorporateCreditCard)
                        {
                            var cC = new CCorporateCreditCard();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // BusinessTrip
                        else if (type == (int)CConstValue.Approval.BusinessTrip)
                        {
                            var cC = new CBusinessTrip();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // PackageProgram
                        else if (type == (int)CConstValue.Approval.Package)
                        {
                            var cC = new CPackageProgram();
                            var c  = cC.GetPackageProgram(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // Expense
                        else if (type == (int)CConstValue.Approval.Expense)
                        {
                            var cC = new CExpense();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // Purchase Order
                        else if (type == (int)CConstValue.Approval.PurchaseOrder)
                        {
                            var cP = new CPurchaseOrder();
                            var c  = cP.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cP.Update(c);
                        }
                        // Hire
                        else if (type == (int)CConstValue.Approval.Hire)
                        {
                            var cC = new CHire();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // Vacation
                        else if (type == (int)CConstValue.Approval.Vacation)
                        {
                            var cC = new CVacation();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        //Scholarship
                        else if (type == (int)CConstValue.Approval.Scholarship)
                        {
                            var cC = new CScholarship();
                            var c  = cC.Get(id);
                            idNumber         = c.ScholarshipMasterNo;
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;
                            cC.Update(c);
                        }
                        //Promotion
                        else if (type == (int)CConstValue.Approval.Promotion)
                        {
                            var cC = new CPromotion();
                            var c  = cC.Get(id);
                            idNumber         = c.PromotionMasterNo;
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;
                            cC.Update(c);
                        }
                        // CreditMemo
                        else if (type == (int)CConstValue.Approval.CreditMemoPayout)
                        {
                            var cC = new CCreditMemoPayout();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;
                            cC.Update(c);
                        }

                        // update approvalHistory
                        cApprovalHistory.Update(approvalHistory);

                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToRequestUser, id, idNumber, CurrentUserId);

                        RunClientScript("Close();");
                    }
                    catch (Exception ex)
                    {
                        ShowMessage(ex.Message);
                    }
                }
            }
        }
Пример #4
0
        public DataTable GetInvoiceData()
        {
            // student insurance
            var cStudent = new CStudent();
            var student  = cStudent.Get(Id);

            DataTable table = new DataTable();

            table.Columns.Add("InvoiceCoaItemId", typeof(int));
            table.Columns.Add("StandardPrice", typeof(decimal));
            table.Columns.Add("StudentPrice", typeof(decimal));
            table.Columns.Add("AgencyPrice", typeof(decimal));
            table.Columns.Add("Remark", typeof(string));
            table.Columns.Add("InvoiceItemId", typeof(int));

            // Tuition
            if (tbPrgTuition.Value.ToString() != "0" && tbPrgTuition.Value.ToString() != string.Empty)
            {
                table.Rows.Add((int)CConstValue.InvoiceCoaItem.TuitionBasic, tbPrgStandardTuition.Value, tbPrgTuition.Value, tbPrgTuition.Value, string.Empty, 0);

                // Scholarship
                double scholarshipPrice = 0;
                ScholarshipId = null;
                ImageScholarshipSuccess.Visible = false;
                ImageScholarshipFail.Visible    = true;
                RadNumericTextBoxAvailableScholarshipAmount.Text = string.Empty;
                RadNumericTextBoxAvailableScholarshipWeeks.Text  = string.Empty;

                if (RadTextBoxScholarship.Text != string.Empty)
                {
                    if (student != null && !string.IsNullOrEmpty(ddlAgency.SelectedValue))
                    {
                        var cScholarship = new CScholarship();
                        var scholarship  = cScholarship.GetScholarship(RadTextBoxScholarship.Text.Replace("-", string.Empty), student.SiteLocationId, Convert.ToInt32(ddlProgramWeeks.Text), Convert.ToInt32(ddlAgency.SelectedValue));
                        if (scholarship != null)
                        {
                            // search scholarship with availalble value over than 1
                            var vwScholarship = cScholarship.GetVwScholarship(scholarship.ScholarshipId);
                            if (vwScholarship != null)
                            {
                                // if invoice doesn't have, it can be null
                                decimal availableAmount = vwScholarship.AvailableAmount ?? 0;
                                int     availableWeeks  = vwScholarship.AvailableWeeks ?? 0;

                                if (scholarship.Amount != null)
                                {
                                    RadNumericTextBoxAvailableScholarshipAmount.Value = (double)availableAmount;

                                    if (!string.IsNullOrEmpty(RadNumericTextBoxScholarshipAmount.Text))
                                    {
                                        if ((double)availableAmount < RadNumericTextBoxScholarshipAmount.Value)
                                        {
                                            RadNumericTextBoxScholarshipAmount.Value = (double)availableAmount;
                                        }
                                    }
                                    else
                                    {
                                        RadNumericTextBoxScholarshipAmount.Value = (double)availableAmount;
                                    }
                                    scholarshipPrice = (double)RadNumericTextBoxScholarshipAmount.Value * -1;

                                    RadNumericTextBoxScholarshipWeeks.Text      = string.Empty;
                                    RadButtonAvailableScholarshipAmount.Checked = true;
                                    RadButtonAvailableScholarshipWeeks.Checked  = false;
                                }
                                else
                                {
                                    RadNumericTextBoxAvailableScholarshipWeeks.Value = availableWeeks;

                                    if (!string.IsNullOrEmpty(RadNumericTextBoxScholarshipWeeks.Text))
                                    {
                                        if ((double)availableWeeks < RadNumericTextBoxScholarshipWeeks.Value)
                                        {
                                            RadNumericTextBoxScholarshipWeeks.Value = (double)availableWeeks;
                                        }
                                    }
                                    else
                                    {
                                        RadNumericTextBoxScholarshipWeeks.Value = (double)availableWeeks;
                                    }
                                    // todo: cal week for scholarship.
                                    // cal weeks !!!!!!!!!!!!!!!!!!
                                    scholarshipPrice = (double)RadNumericTextBoxScholarshipWeeks.Value;
                                    RadNumericTextBoxScholarshipAmount.Value = scholarshipPrice;

                                    RadButtonAvailableScholarshipAmount.Checked = false;
                                    RadButtonAvailableScholarshipWeeks.Checked  = true;
                                }

                                table.Rows.Add((int)CConstValue.InvoiceCoaItem.TuitionScholarship, 0, 0, scholarshipPrice, string.Empty, 0);

                                ScholarshipId = scholarship.ScholarshipId;
                                ImageScholarshipSuccess.Visible = true;
                                ImageScholarshipFail.Visible    = false;
                            }
                        }
                    }
                }

                // Commission
                if (tbCommissionRate.Value.ToString() != "0" && tbCommissionRate.Value.ToString() != string.Empty)
                {
                    table.Rows.Add((int)CConstValue.InvoiceCoaItem.CommissionTuition, 0, 0, (tbPrgTuition.Value + scholarshipPrice) * (tbCommissionRate.Value / -100), string.Empty, 0);
                }

                // Promotion
                PromotionId = null;
                ImagePromotionSuccess.Visible = false;
                ImagePromotionFail.Visible    = true;
                if (RadTextBoxPromotion.Text != string.Empty)
                {
                    if (student != null)
                    {
                        var cPromotion = new CPromotion();
                        var promotion  = cPromotion.GetPromotion(RadTextBoxPromotion.Text, student.SiteLocationId);
                        if (promotion != null)
                        {
                            PromotionId = promotion.PromotionId;
                            ImagePromotionSuccess.Visible = true;
                            ImagePromotionFail.Visible    = false;
                        }
                    }
                }

                // from Other fee info
                if (!string.IsNullOrEmpty(ddlProgramName.SelectedValue))
                {
                    var cProgramOtherFeeInfo = new CProgramOtherFeeInfo();
                    var programOtherFeeInfo  = cProgramOtherFeeInfo.Get(Convert.ToInt32(ddlProgramName.SelectedValue));
                    if (programOtherFeeInfo != null)
                    {
                        // other fees
                        var regFee = programOtherFeeInfo.RegFee + programOtherFeeInfo.JRegFee;
                        if (regFee > 0)
                        {
                            table.Rows.Add((int)CConstValue.InvoiceCoaItem.Registration, regFee, regFee, regFee, string.Empty, 0);
                        }

                        var materialFee = programOtherFeeInfo.AcademicFee + programOtherFeeInfo.MaterialFee + programOtherFeeInfo.UniformFee + programOtherFeeInfo.SupplyFee;
                        if (materialFee > 0)
                        {
                            table.Rows.Add((int)CConstValue.InvoiceCoaItem.MaterialOthers, materialFee, materialFee, materialFee, string.Empty, 0);
                        }

                        var testFee = programOtherFeeInfo.TestFee + programOtherFeeInfo.ExamFee;
                        if (testFee > 0)
                        {
                            table.Rows.Add((int)CConstValue.InvoiceCoaItem.TestExamFee, testFee, testFee, testFee, string.Empty, 0);
                        }

                        var internshipFee = programOtherFeeInfo.InternFee + programOtherFeeInfo.PracticeFee + programOtherFeeInfo.LCFee + programOtherFeeInfo.SDFee + programOtherFeeInfo.UPFee;
                        if (internshipFee > 0)
                        {
                            table.Rows.Add((int)CConstValue.InvoiceCoaItem.InternshipBasic, internshipFee, internshipFee, internshipFee, string.Empty, 0);
                        }

                        var administration = programOtherFeeInfo.ACFee + programOtherFeeInfo.AdminFee + programOtherFeeInfo.UAGFee;
                        if (administration > 0)
                        {
                            table.Rows.Add((int)CConstValue.InvoiceCoaItem.Administration, administration, administration, administration, string.Empty, 0);
                        }

                        var certificateFee = programOtherFeeInfo.CFee;
                        if (certificateFee > 0)
                        {
                            table.Rows.Add((int)CConstValue.InvoiceCoaItem.ServiceCertificate, certificateFee, certificateFee, certificateFee, string.Empty, 0);
                        }

                        var otherFee = programOtherFeeInfo.OtherFee;
                        if (otherFee > 0)
                        {
                            table.Rows.Add((int)CConstValue.InvoiceCoaItem.Other, otherFee, otherFee, otherFee, string.Empty, 0);
                        }
                    }
                }

                if (student != null)
                {
                    if (student.Insurance)
                    {
                        // 33
                        table.Rows.Add((int)CConstValue.InvoiceCoaItem.Insurance, student.InsuranceTotal, student.InsuranceTotal, student.InsuranceTotal);
                    }
                }

                // agency check
                if (string.IsNullOrEmpty(ddlAgency.SelectedValue))
                {
                    foreach (DataRow dr in table.Rows)
                    {
                        dr["AgencyPrice"] = 0;
                    }
                }
            }
            return(table);
        }
Пример #5
0
        protected void ToolbarButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "Save")
            {
                if (IsValid)
                {
                    if (!string.IsNullOrEmpty(ddlAgency.SelectedValue) && (tbCommissionRate.Value == 0 || tbCommissionRate.Value == null))
                    {
                        ShowMessage("Commision Rate should be written.");
                        return;
                    }

                    var cScholarship = new CScholarship();
                    if (ScholarshipId != null)
                    {
                        var scholarship = cScholarship.GetVwScholarship((int)ScholarshipId);
                        if (RadButtonAvailableScholarshipAmount.Checked)
                        {
                            if (scholarship.AvailableAmount == 0 || (double)scholarship.AvailableAmount < RadNumericTextBoxScholarshipAmount.Value)
                            {
                                ShowMessage("Scholarship Amount is bigger than availalble Amount.");
                                return;
                            }
                        }
                        else
                        {
                            if (scholarship.AvailableWeeks == 0 || (double)scholarship.AvailableWeeks < RadNumericTextBoxScholarshipWeeks.Value)
                            {
                                ShowMessage("Scholarship Weeks are bigger than availalble Weeks.");
                                return;
                            }
                        }
                    }

                    var cProgramReg = new CProgramRegistration();
                    var programReg  = new ProgramRegistration();

                    programReg.StudentId = Id;
                    programReg.ProgramId = Convert.ToInt32(ddlProgramName.SelectedValue);

                    programReg.StartDate = tbPrgStartDate.SelectedDate;
                    programReg.EndDate   = tbPrgEndDate.SelectedDate;
                    programReg.ProgramRegistrationType = 9;

                    if (!string.IsNullOrEmpty(ddlProgramWeeks.SelectedValue))
                    {
                        programReg.Weeks = Convert.ToInt32(ddlProgramWeeks.SelectedValue);
                    }

                    if (!string.IsNullOrEmpty(ddlPrgHours.SelectedValue))
                    {
                        programReg.HrsStatus = Convert.ToInt32(ddlPrgHours.SelectedValue);
                    }

                    programReg.CreatedId   = CurrentUserId;
                    programReg.CreatedDate = DateTime.Now;

                    var proRegId = cProgramReg.Add(programReg); //DB:ProgramRegistration

                    if (proRegId > 0)
                    {
                        var cInvoice = new CInvoice();
                        var invoice  = new Invoice();

                        invoice.ProgramRegistrationId = proRegId;
                        invoice.StudentId             = Id;
                        if (!string.IsNullOrEmpty(ddlAgency.SelectedValue))
                        {
                            invoice.AgencyId             = Convert.ToInt32(ddlAgency.SelectedValue);
                            invoice.IsAgencySeasonalRate = RadButtonAgencyRateSeasonal.Checked;
                            invoice.AgencyRate           = tbCommissionRate.Value;
                        }

                        if (ScholarshipId != null)
                        {
                            invoice.ScholarshipId = ScholarshipId;
                            if (RadButtonAvailableScholarshipAmount.Checked)
                            {
                                invoice.ScholarshipAmount = (decimal)RadNumericTextBoxScholarshipAmount.Value;
                            }
                            else
                            {
                                invoice.ScholarshipAmount = (decimal)RadNumericTextBoxScholarshipAmount.Value;
                                invoice.ScholarshipWeeks  = (int)RadNumericTextBoxScholarshipWeeks.Value;
                            }
                        }
                        invoice.PromotionId = PromotionId;

                        invoice.SiteLocationId = CurrentSiteLocationId;
                        invoice.InvoiceType    = (int)CConstValue.InvoiceType.General; //General Invoice(IN)


                        invoice.Status      = (int)CConstValue.InvoiceStatus.Pending; // Pending
                        invoice.CreatedId   = CurrentUserId;
                        invoice.CreatedDate = DateTime.Now;

                        var invoiceId = cInvoice.Add(invoice); //DB:Invoice

                        if (invoiceId > 0)
                        {
                            var cInvoiceItem = new CInvoiceItem();

                            foreach (GridDataItem item in _radGridInvoiceItems.Items)
                            {
                                var invoiceCoaItemId = (RadDropDownList)item.FindControl("ddlInvoiceItems");
                                var standardPrice    = (Label)item.FindControl("lblStandardPrice");
                                var studentPrice     = (Label)item.FindControl("lblStudentPrice");
                                var agencyPrice      = (Label)item.FindControl("lblAgencyPrice");

                                var invoiceItem = new InvoiceItem();
                                invoiceItem.InvoiceId = invoiceId;

                                invoiceItem.InvoiceCoaItemId = Convert.ToInt32(invoiceCoaItemId.SelectedValue);
                                invoiceItem.StandardPrice    = Convert.ToDecimal(standardPrice.Text.Replace("$", string.Empty));
                                invoiceItem.StudentPrice     = Convert.ToDecimal(studentPrice.Text.Replace("$", string.Empty));
                                invoiceItem.AgencyPrice      = Convert.ToDecimal(agencyPrice.Text.Replace("$", string.Empty));

                                invoiceItem.CreatedId   = CurrentUserId;
                                invoiceItem.CreatedDate = DateTime.Now;

                                cInvoiceItem.Add(invoiceItem);
                            }

                            // disable used scholarship
                            if (ScholarshipId != null)
                            {
                                var sScholarship = new CScholarship();
                                var scholarship  = sScholarship.Get((int)ScholarshipId);
                                scholarship.IsActive = true;
                                sScholarship.Update(scholarship);
                            }

                            RunClientScript("Close();");
                        }
                        else
                        {
                            ShowMessage("failed to update inqury (Add Invoice Items)");
                        }
                    }
                    else
                    {
                        ShowMessage("failed to update inqury (Invoice)");
                    }
                }
            }
            else
            {
                ShowMessage("Fill in data");
            }
        }
Пример #6
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "Cancel" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    try
                    {
                        var type = Convert.ToInt32(hfType.Value);
                        var id   = Convert.ToInt32(hfId.Value);

                        var cApprovalHistory = new CApprovalHistory();
                        var approvalHistory  = cApprovalHistory.Get(type, id, CurrentUserId);

                        bool isExists = true;
                        if (approvalHistory == null)
                        {
                            approvalHistory = new ApprovalHistory();
                            approvalHistory.ApprovalUser = CurrentUserId;
                            isExists = false;
                        }

                        approvalHistory.ApprovalDate = DateTime.Now;
                        approvalHistory.ApprovalMemo = tbRemark.Text;
                        approvalHistory.ApprovalStep = (int)CConstValue.ApprovalStatus.Canceled;

                        // update approvalHistory
                        if (isExists)
                        {
                            cApprovalHistory.Update(approvalHistory);
                        }

                        if (type == (int)CConstValue.Approval.Refund)
                        {
                            var cRefund = new CRefund();
                            var refund  = cRefund.Get(id);
                            refund.ApprovalDate   = approvalHistory.ApprovalDate;
                            refund.ApprovalId     = approvalHistory.ApprovalUser;
                            refund.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            refund.ApprovalStatus = approvalHistory.ApprovalStep;

                            if (cRefund.Update(refund))
                            {
                                var cInvoiceInfo = new CInvoice();
                                var invoiceInfo  = cInvoiceInfo.Get(refund.InvoiceId);

                                var cOriginalInvoiceInfo = new CInvoice();
                                var originalInvoiceInfo  = cOriginalInvoiceInfo.Get(Convert.ToInt32(invoiceInfo.OriginalInvoiceId));

                                invoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Cancelled_RF; // Canceled_R
                                invoiceInfo.UpdatedId = CurrentUserId;

                                originalInvoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Invoiced; // Invoiced
                                originalInvoiceInfo.UpdatedId = CurrentUserId;

                                cInvoiceInfo.Update(invoiceInfo);
                                cOriginalInvoiceInfo.Update(originalInvoiceInfo);
                            }
                        }
                        else if (type == (int)CConstValue.Approval.Agency)
                        {
                            var cAgency = new CAgency();
                            var agency  = cAgency.Get(id);
                            agency.ApprovalDate   = approvalHistory.ApprovalDate;
                            agency.ApprovalId     = approvalHistory.ApprovalUser;
                            agency.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            agency.ApprovalStatus = approvalHistory.ApprovalStep;

                            cAgency.Update(agency);
                        }
                        else if (type == (int)CConstValue.Approval.CreditMemoPayout)
                        {
                            var cCreditMemoPayout = new CCreditMemoPayout();
                            var creditMemoPayout  = cCreditMemoPayout.Get(id);
                            creditMemoPayout.ApprovalDate   = approvalHistory.ApprovalDate;
                            creditMemoPayout.ApprovalId     = approvalHistory.ApprovalUser;
                            creditMemoPayout.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            creditMemoPayout.ApprovalStatus = approvalHistory.ApprovalStep;

                            cCreditMemoPayout.Update(creditMemoPayout);
                        }
                        else if (type == (int)CConstValue.Approval.Package)
                        {
                            var cPackageProgram = new CPackageProgram();
                            var packageProgram  = cPackageProgram.GetPackageProgram(id);
                            packageProgram.ApprovalDate   = approvalHistory.ApprovalDate;
                            packageProgram.ApprovalId     = approvalHistory.ApprovalUser;
                            packageProgram.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            packageProgram.ApprovalStatus = approvalHistory.ApprovalStep;

                            cPackageProgram.Update(packageProgram);
                        }
                        else if (type == (int)CConstValue.Approval.Promotion)
                        {
                            var cPromotion = new CPromotion();
                            var promotion  = cPromotion.Get(id);
                            promotion.ApprovalDate   = approvalHistory.ApprovalDate;
                            promotion.ApprovalId     = approvalHistory.ApprovalUser;
                            promotion.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            promotion.ApprovalStatus = approvalHistory.ApprovalStep;

                            cPromotion.Update(promotion);
                        }
                        else if (type == (int)CConstValue.Approval.Scholarship)
                        {
                            var cScholarship = new CScholarship();
                            var scholarship  = cScholarship.Get(id);
                            scholarship.ApprovalDate   = approvalHistory.ApprovalDate;
                            scholarship.ApprovalId     = approvalHistory.ApprovalUser;
                            scholarship.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            scholarship.ApprovalStatus = approvalHistory.ApprovalStep;

                            cScholarship.Update(scholarship);
                        }
                        else if (type == (int)CConstValue.Approval.CorporateCreditCard)
                        {
                            var cCorporateCreditCard = new CCorporateCreditCard();
                            var corporateCreditCard  = cCorporateCreditCard.Get(id);
                            corporateCreditCard.ApprovalDate   = approvalHistory.ApprovalDate;
                            corporateCreditCard.ApprovalId     = approvalHistory.ApprovalUser;
                            corporateCreditCard.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            corporateCreditCard.ApprovalStatus = approvalHistory.ApprovalStep;

                            cCorporateCreditCard.Update(corporateCreditCard);
                        }
                        // BusinessTrip
                        else if (type == (int)CConstValue.Approval.BusinessTrip)
                        {
                            var cBusinessTrip = new CBusinessTrip();
                            var businessTrip  = cBusinessTrip.Get(id);
                            businessTrip.ApprovalDate   = approvalHistory.ApprovalDate;
                            businessTrip.ApprovalId     = approvalHistory.ApprovalUser;
                            businessTrip.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            businessTrip.ApprovalStatus = approvalHistory.ApprovalStep;

                            cBusinessTrip.Update(businessTrip);
                        }
                        // Purchase Order
                        else if (type == (int)CConstValue.Approval.PurchaseOrder)
                        {
                            var cPurchaseOrder = new CPurchaseOrder();
                            var purchaseOrder  = cPurchaseOrder.Get(id);
                            purchaseOrder.ApprovalDate   = approvalHistory.ApprovalDate;
                            purchaseOrder.ApprovalId     = approvalHistory.ApprovalUser;
                            purchaseOrder.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            purchaseOrder.ApprovalStatus = approvalHistory.ApprovalStep;

                            cPurchaseOrder.Update(purchaseOrder);
                        }
                        // Expense
                        else if (type == (int)CConstValue.Approval.Expense)
                        {
                            var cExpense = new CExpense();
                            var expense  = cExpense.Get(id);
                            expense.ApprovalDate   = approvalHistory.ApprovalDate;
                            expense.ApprovalId     = approvalHistory.ApprovalUser;
                            expense.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            expense.ApprovalStatus = approvalHistory.ApprovalStep;

                            cExpense.Update(expense);
                        }
                        // Hire
                        else if (type == (int)CConstValue.Approval.Hire)
                        {
                            var cHire = new CHire();
                            var hire  = cHire.Get(id);
                            hire.ApprovalDate   = approvalHistory.ApprovalDate;
                            hire.ApprovalId     = approvalHistory.ApprovalUser;
                            hire.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            hire.ApprovalStatus = approvalHistory.ApprovalStep;

                            cHire.Update(hire);
                        }
                        // Vacation
                        else if (type == (int)CConstValue.Approval.Vacation)
                        {
                            var cVacation = new CVacation();
                            var vacation  = cVacation.Get(id);
                            vacation.ApprovalDate   = approvalHistory.ApprovalDate;
                            vacation.ApprovalId     = approvalHistory.ApprovalUser;
                            vacation.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            vacation.ApprovalStatus = approvalHistory.ApprovalStep;

                            cVacation.Update(vacation);
                        }

                        RunClientScript("Close();");
                    }
                    catch (Exception ex)
                    {
                        ShowMessage(ex.Message);
                    }
                }
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Id = Convert.ToInt32(Request["Id"]);

            if (!IsPostBack)
            {
                var cAgency = new CAgency();
                ddlAgencyName.DataSource     = cAgency.GetAgency(CurrentSiteLocationId);
                ddlAgencyName.DataTextField  = "Name";
                ddlAgencyName.DataValueField = "Value";
                ddlAgencyName.Filter         = (RadComboBoxFilter)Convert.ToInt32(1);
                ddlAgencyName.Items.Insert(0, new RadComboBoxItem("Type a Agency Name"));
                ddlAgencyName.DataBind();

                //LoadSite();

                // new
                if (Request["type"] == "0")
                {
                    GetSiteLocation(false);
                }
                // modify
                else
                {
                    GetSiteLocation(true);

                    var cP = new CScholarship().Get(Id);

                    foreach (RadComboBoxItem item in ddlAgencyName.Items)
                    {
                        if (item.Value == cP.AgencyId.ToString())
                        {
                            item.Selected = true;
                            break;
                        }
                    }

                    if (cP.Amount == 0)
                    {
                        rbWeeks.Checked = true;
                        tbWeeks.Text    = cP.Weeks.ToString();
                    }
                    else
                    {
                        rbAmount.Checked = true;
                        RadNumericTextBoxAmount.Value = (double)cP.Amount;
                    }
                    tbExpireDate.SelectedDate = cP.ExpireDate;

                    foreach (RadComboBoxItem item in RadComboBoxMinimum.Items)
                    {
                        if (item.Value == cP.MininumRegistrationWeeks.ToString())
                        {
                            item.Selected = true;
                            break;
                        }
                    }

                    tbComment.Text = cP.Memo;
                }
            }
        }
Пример #8
0
        //protected void LoadSite()
        //{
        //    var global = new CGlobal();

        //    RadComboBoxSite.DataSource = global.GetSiteId();
        //    RadComboBoxSite.DataTextField = "Name";
        //    RadComboBoxSite.DataValueField = "Value";
        //    RadComboBoxSite.DataBind();
        //    RadComboBoxSite.Items.Insert(0, new RadComboBoxItem("- Select Site - "));
        //}

        protected void StudentButtonClicked(object sender, RadToolBarEventArgs e)
        {
            switch (e.Item.Text)
            {
            case "TempSave":
            case "Request":
                var cScholarshipReg = new CScholarship();
                var scholarshipReg  = new Erp2016.Lib.Scholarship();
                // new
                if (Request["type"] == "0")
                {
                    scholarshipReg             = new Erp2016.Lib.Scholarship();
                    scholarshipReg.CreatedId   = CurrentUserId;
                    scholarshipReg.CreatedDate = DateTime.Now;
                }
                // modify
                else
                {
                    scholarshipReg = cScholarshipReg.Get(Id);
                }

                scholarshipReg.AgencyId = Convert.ToInt32(ddlAgencyName.SelectedValue);
                if (rbAmount.Checked)
                {
                    scholarshipReg.Amount = Convert.ToDecimal(RadNumericTextBoxAmount.Text == string.Empty ? "0" : RadNumericTextBoxAmount.Text);
                }
                if (rbWeeks.Checked)
                {
                    scholarshipReg.Weeks = Convert.ToInt32(tbWeeks.Text);
                }

                scholarshipReg.ExpireDate = Convert.ToDateTime(tbExpireDate.SelectedDate);
                scholarshipReg.MininumRegistrationWeeks = Convert.ToInt32(RadComboBoxMinimum.SelectedValue);
                scholarshipReg.Memo      = tbComment.Text;
                scholarshipReg.CreatedId = CurrentUserId;
                scholarshipReg.IsActive  = false;

                int scholarshipId;

                // new
                if (Request["type"] == "0")
                {
                    scholarshipReg.IsActive = false;
                    scholarshipId           = cScholarshipReg.Add(scholarshipReg);
                }
                // modify
                else
                {
                    scholarshipReg.UpdatedId   = CurrentUserId;
                    scholarshipReg.UpdatedDate = DateTime.Now;
                    cScholarshipReg.Update(scholarshipReg);

                    scholarshipId = scholarshipReg.ScholarshipId;
                }

                var cScholarshipSiteLocation = new CScholarshipSiteLocation();
                cScholarshipSiteLocation.DelScholarshipSiteLocation(scholarshipId);

                foreach (var siteLocation in RadComboBoxSiteLocation.CheckedItems)
                {
                    var scholarshipSiteLocation = new ScholarshipSiteLocation()
                    {
                        CreatedId      = CurrentUserId,
                        ScholarshipId  = scholarshipId,
                        SiteLocationId = Convert.ToInt32(siteLocation.Value),
                        CreatedDate    = DateTime.Now
                    };
                    cScholarshipSiteLocation.Add(scholarshipSiteLocation);
                }

                if (e.Item.Text == "TempSave")
                {
                    RunClientScript("Close();");
                }
                else
                {
                    var cApprovalHistory = new CApprovalHistory();
                    cApprovalHistory.DelApprovalHistory((int)CConstValue.Approval.Scholarship, scholarshipId);

                    var approval = new CApproval().ApproveRequstCreate((int)CConstValue.Approval.Scholarship, CurrentUserId, scholarshipId);
                    if (approval > 0)
                    {
                        var cScholar = new CScholarship();
                        var scholar  = cScholar.Get(scholarshipId);
                        scholar.ApprovalStatus = approval;
                        scholar.ApprovalId     = CurrentUserId;
                        scholar.ApprovalDate   = DateTime.Now;
                        cScholar.Update(scholar);

                        new CMail().SendMail(CConstValue.Approval.Scholarship, CConstValue.MailStatus.ToApproveUser, scholar.ScholarshipId, scholar.ScholarshipMasterNo, CurrentUserId);

                        RunClientScript("Close();");
                    }
                    else
                    {
                        ShowMessage("error requesting");
                    }
                }
                break;

            case "Close":
                RunClientScript("Close();");
                break;
            }
        }
Пример #9
0
        protected void ToolbarButtonClick(object sender, RadToolBarEventArgs e)
        {
            switch (e.Item.Text)
            {
            case "Request":
                if (IsValid)
                {
                    var cInvoice = new CInvoice();
                    var original = cInvoice.Get(InvoiceId);
                    if (original != null)
                    {
                        original.Status    = (int)CConstValue.InvoiceStatus.Cancelled_CC;
                        original.UpdatedId = CurrentUserId;

                        if (cInvoice.Update(original))
                        {
                            var cCancel = new CCancel();
                            var cancel  = new Cancel();

                            cancel.InvoiceId = original.InvoiceId;
                            cancel.ApplyDate = RadDatePickerApply.SelectedDate.Value;
                            cancel.Reason    = RadTextBoxReason.Text;
                            cancel.IsActive  = true;
                            cancel.CreatedId = CurrentUserId;

                            int cancelId = cCancel.Add(cancel);
                            if (cancelId > 0)
                            {
                                // save uploading file
                                FileDownloadList1.SaveFile(cancelId);

                                // Program
                                if (original.ProgramRegistrationId != null)
                                {
                                    var cProgramRegiInfo = new CProgramRegistration();
                                    var programRegiInfo  = cProgramRegiInfo.Get(Convert.ToInt32(original.ProgramRegistrationId));
                                    programRegiInfo.UpdatedId               = CurrentUserId;
                                    programRegiInfo.UpdatedDate             = DateTime.Now;
                                    programRegiInfo.ProgramRegistrationType = 12;     // cancel

                                    cProgramRegiInfo.Update(programRegiInfo);
                                }
                                // Homestay
                                else if (original.HomestayRegistrationId != null)
                                {
                                    var cHomestayStudentRequest = new CHomestayStudentRequest();
                                    var homestayStudentRequest  = cHomestayStudentRequest.GetHomestayStudentRequest(Convert.ToInt32(original.HomestayRegistrationId));
                                    homestayStudentRequest.UpdateUserId          = CurrentUserId;
                                    homestayStudentRequest.UpdatedDate           = DateTime.Now;
                                    homestayStudentRequest.HomestayStudentStatus = 1;     // cancel


                                    cHomestayStudentRequest.Update(homestayStudentRequest);
                                }
                                // Dormitory
                                else if (original.DormitoryRegistrationId != null)
                                {
                                    var cDormitoryStudentRequest = new CDormitoryRegistrations();
                                    var dormitoryStudentRequest  = cDormitoryStudentRequest.GetDormitoryStudentRequest(Convert.ToInt32(original.DormitoryRegistrationId));
                                    dormitoryStudentRequest.DormitoryStudentStatus = 1;     // cancel
                                    dormitoryStudentRequest.UpdatedId   = CurrentUserId;
                                    dormitoryStudentRequest.UpdatedDate = DateTime.Now;

                                    cDormitoryStudentRequest.Update(dormitoryStudentRequest);
                                }

                                if (original.ScholarshipId != null)
                                {
                                    var cScholarship = new CScholarship();
                                    var scholarship  = cScholarship.Get((int)original.ScholarshipId);
                                    if (scholarship != null)
                                    {
                                        scholarship.IsActive = true;
                                        cScholarship.Update(scholarship);
                                    }
                                }

                                RunClientScript("Close();");
                            }
                            else
                            {
                                ShowMessage("failed to update inqury (Add Cancel)");
                            }
                        }
                        else
                        {
                            ShowMessage("failed to update inqury (Update Original Invoice)");
                        }
                    }
                    else
                    {
                        ShowMessage("failed to update inqury (Original Invoice is null)");
                    }
                }
                break;

            case "Close":
                RunClientScript("Close();");
                break;
            }
        }
Пример #10
0
        public RLetterOfAcceptanceInTable(int invoiceId)
        {
            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();

            var invoice = new CInvoice().Get(invoiceId);

            if (invoice?.ProgramRegistrationId == null)
            {
                return;
            }

            var programRegistration = new CProgramRegistration().Get((int)invoice.ProgramRegistrationId);

            if (programRegistration == null)
            {
                return;
            }

            var cStudent = new CStudent();
            var student  = cStudent.Get((int)invoice.StudentId);

            if (student == null)
            {
                return;
            }

            var program      = new CProgram().Get(programRegistration.ProgramId);
            var siteLocation = new CSiteLocation().Get(student.SiteLocationId);
            var site         = new CSite().Get(siteLocation.SiteId);

            textBoxDLI.Value         = $@"Designated learning institution number (DLI #) : {"O19375754382"}";
            textBoxDateOfIssue.Value = $@"Date of Issue : {DateTime.Today.ToString("MM-dd-yy")}";

            htmlTextBoxFaimlyName.Value           = $@"1. Family Name : <br><b>{student.LastName1}</b>";
            htmlTextBoxFirstName.Value            = $@"2. First Name and Initials : <br><b>{student.FirstName}</b>";
            htmlTextBoxDateOfBirth.Value          = $@"3. Date of Birth : <br><b>{student.DOB?.ToString("MM-dd-yy")}</b>";
            htmlTextBoxStudentId.Value            = $@"4. Student ID Number : <br><b>{student.StudentNo}</b>";
            htmlTextBoxStudentFull.Value          = $@"5. Student Full Mailing Address : <br><b>{student.Address1InCanada}</b>";
            htmlTextBoxDates.Value                = $@"6. Dates : <br>Start Date : <b>{programRegistration.StartDate?.ToString("MM-dd-yy")}</b><br>Completion Date : <b>{programRegistration.EndDate?.ToString("MM-dd-yy")}</b>";
            htmlTextBoxNameOfSchool.Value         = $@"7. Name of School/Institution(include public or private) : <br><b>{site.Name}</b>";
            htmlTextBoxLevelOfStudy.Value         = $@"8. Level of Study : <br><b>{"N/A"}</b>";
            htmlTextBoxProgram.Value              = $@"9. Program/Major/Course : <br><b>{program.ProgramFullName + " " + (programRegistration.HrsStatus == null ? string.Empty : "(" + programRegistration.HrsStatus + "/week)")}</b>";
            htmlTextBoxHoursOfInstruction.Value   = $@"10. Hours of Instruction per Week : <br><b>{programRegistration.Weeks}</b>";
            htmlTextBoxAcademicYear.Value         = $@"11. Academic Year of Study which the student will enter (e.g., Year 2 of 3 Year Program)<br><b>{"N/A"}</b>";
            htmlTextBoxLateRegistrationDate.Value = $@"12. Late Registration Date : <br><b>{"N/A"}</b>";

            var vwStudentContract = new CStudent().GetVwStudentContract(invoiceId);
            var isFullPayment     = false;

            if (vwStudentContract?.DepositConfirmCnt == vwStudentContract?.PaymentCnt && vwStudentContract.Balance == 0)
            {
                isFullPayment = true;
            }

            htmlTextBoxConditionOfAcceptance.Value = $@"13. Condition of Acceptance : (must be paid in full at least 2 weeks before start date)<br><b>{(isFullPayment ? "Full Fee Payment" : "Not fully Fee Payment")}</b>";

            var invoiceItemList = new CInvoiceItem().GetInvoiceItems(invoiceId);
            var tuitionFee      = invoiceItemList.FirstOrDefault(x => x.InvoiceCoaItemId == (int)CConstValue.InvoiceCoaItem.TuitionBasic);

            htmlTextBoxEstimatedTuitionFees.Value = $@"14. Estimated Tuition Fees : (not including homestay accommodation fee)<br>Tuition Fee : <b>${tuitionFee}</b>";

            string scholarshipMasterNo = string.Empty;

            if (invoice.ScholarshipId != null)
            {
                scholarshipMasterNo = new CScholarship().Get((int)invoice.ScholarshipId)?.ScholarshipMasterNo;
            }

            htmlTextBoxScholarship.Value               = $@"15. Scholarship/Teaching Assistantship: <br><b>{scholarshipMasterNo}</b>";
            htmlTextBoxExchangeStudent.Value           = $@"16. Exchange Student (yes/no) : <br><b>{"No"}</b>";
            htmlTextBoxLicensingInformation.Value      = $@"17. Licensing Information where applicable for Private Institution (yes/no/not applicable): <br><b>{"N/A"}</b>";
            htmlTextBoxIfDestinedForQuebec.Value       = $@"18. If destined for Quebec, has CAQ information been sent to student (yes/no/not applicable) : <br><b>{"N/A"}</b>";
            htmlTextBoxGuardianship.Value              = $@"19. Guardianship/Custodianship details if applicable : <br><b>{"N/A"}</b>";
            htmlTextBoxCredentials.Value               = $@"20. Credentials : <br><b>{site.Name} Certificates and/or Diploma</b>";
            htmlTextBoxRequirementsForSuccessful.Value = $@"21. Requirements for successful program completion : <br><b>{"70% grade and 85% attendance"}</b>";
            htmlTextBoxSignatureOfInstitution.Value    = $@"22. Signature of Institution Representative : <br>";

            string name     = string.Empty;
            string position = string.Empty;

            switch (siteLocation.SiteId)
            {
            // CAC
            case 2:
                name     = "Christine Jang";
                position = "Site Administrator";
                break;

            default:
                name     = string.Empty;
                position = string.Empty;
                break;
            }

            htmlTextBoxNameOfInstitution.Value = $@"23. Name of Institution Representative (please print) : <br><b>{name} - {position}</b>";

            htmlTextBoxStudentSignature.Value = $@"24. Student's signature : <br><br><br><br><br>I have read and received a copy this contract and a copy of statement of the student's rights and responsibilities.";

            try
            {
                var logoPath = new CGlobal().GetLogoImagePath((int)invoice.SiteLocationId, CConstValue.ImageType.Logo);
                if (logoPath != string.Empty)
                {
                    pictureBoxCompanyLogo.Value = Image.FromFile(logoPath);
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }

            try
            {
                var signPath = new CGlobal().GetLogoImagePath((int)invoice.SiteLocationId, CConstValue.ImageType.Sign);
                if (signPath != string.Empty)
                {
                    pictureBoxSign.Value = Image.FromFile(signPath);
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }

            try
            {
                var sideLogoPath = new CGlobal().GetLogoImagePath((int)invoice.SiteLocationId, CConstValue.ImageType.LogoSide);
                if (sideLogoPath != string.Empty)
                {
                    pictureBoxSideLogo.Value = Image.FromFile(sideLogoPath);
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
            }
        }
Пример #11
0
        protected void RadGrid1_OnPreRender(object sender, EventArgs e)
        {
            if (ViewState["ScholarshipId"] != null)
            {
                foreach (GridDataItem item in RadGrid1.Items)
                {
                    if (item.GetDataKeyValue("ScholarshipId").ToString() == ViewState["ScholarshipId"].ToString())
                    {
                        if (item.Selected == false)
                        {
                            item.Selected = true;
                            break;
                        }
                    }
                }
            }

            SetApprovalList();
            GetScholarshipHistory();
            GetStudent();

            foreach (RadToolBarItem toolbarItem in RadToolBar1.Items)
            {
                if (RadGrid1.SelectedValue != null)
                {
                    var cScholar = new CScholarship();
                    var scholar  = cScholar.Get(Convert.ToInt32(RadGrid1.SelectedValue));

                    // request active check
                    if (toolbarItem.Text == "Request")
                    {
                        if ((scholar.ApprovalStatus == null || scholar.ApprovalStatus == (int)CConstValue.ApprovalStatus.Revise) && scholar.CreatedId == CurrentUserId)
                        {
                            toolbarItem.Enabled = true;
                        }
                        else
                        {
                            toolbarItem.Enabled = false;
                        }
                    }
                    else if (toolbarItem.Text == "Cancel")
                    {
                        if ((scholar.ApprovalStatus == null ||
                             scholar.ApprovalStatus == (int)CConstValue.ApprovalStatus.Revise ||
                             scholar.ApprovalStatus == (int)CConstValue.ApprovalStatus.Requested) && scholar.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.Scholarship, Convert.ToInt32(scholar.ScholarshipId));

                        // supervisor
                        if ((CurrentUserId == supervisor) &&
                            scholar.ApprovalStatus != (int)CConstValue.ApprovalStatus.Approved &&
                            scholar.ApprovalStatus != (int)CConstValue.ApprovalStatus.Rejected &&
                            scholar.ApprovalStatus != (int)CConstValue.ApprovalStatus.Canceled &&
                            scholar.ApprovalStatus != null &&
                            CurrentUserId != scholar.ApprovalId)
                        {
                            toolbarItem.Enabled = true;
                        }
                        else
                        {
                            toolbarItem.Enabled = false;
                        }
                    }
                }
                else
                {
                    if (toolbarItem.Text == "View" || toolbarItem.Text == "New Scholarship")
                    {
                        continue;
                    }
                    toolbarItem.Enabled = false;
                }
            }
        }
Пример #12
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == @"Approve" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    var type     = Convert.ToInt32(hfType.Value);
                    var id       = Convert.ToInt32(hfId.Value);
                    var idNumber = string.Empty;

                    var cApprovalHistory = new CApprovalHistory();
                    var approvalHistory  = cApprovalHistory.Get(type, id, CurrentUserId);
                    approvalHistory.ApprovalDate = DateTime.Now;
                    approvalHistory.ApprovalMemo = tbRemark.Text;
                    // cal
                    int approvalStatus = cApprovalHistory.CheckApprovalStep(type, id);
                    if (approvalStatus == (int)CConstValue.ApprovalStatus.Approved)
                    {
                        approvalStatus = new CGlobal().GetApprovalValue(type);
                    }
                    approvalHistory.ApprovalStep = approvalStatus;
                    // update approvalHistory
                    cApprovalHistory.Update(approvalHistory);

                    //Refund & Commission
                    if (type == (int)CConstValue.Approval.Refund)
                    {
                        var cRefundInfo = new CRefund();
                        var refundInfo  = cRefundInfo.Get(Convert.ToInt32(hfId.Value));

                        refundInfo.ApprovalDate   = approvalHistory.ApprovalDate;
                        refundInfo.ApprovalId     = approvalHistory.ApprovalUser;
                        refundInfo.ApprovalMemo   = approvalHistory.ApprovalMemo;
                        refundInfo.ApprovalStatus = approvalHistory.ApprovalStep;

                        if (cRefundInfo.Update(refundInfo))
                        {
                            //if last approve
                            if (refundInfo.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                var vwRefund      = cRefundInfo.GetVwRefund(refundInfo.RefundId);
                                var refundAmount  = Math.Abs((decimal)vwRefund.RefundAmount);
                                var sumOfMdfAndCp = new CCreditMemo().GetSumOfMdfAndCp(vwRefund.RefundId);

                                var cCreditMemoPayout = new CCreditMemoPayout();
                                var creditMemoPayout  = cCreditMemoPayout.Get(refundInfo.CreditMemoPayoutId);

                                var cCreditMemo = new CCreditMemo();
                                var creditMemo  = cCreditMemo.Get(creditMemoPayout.CreditMemoId);

                                creditMemo.OriginalCreditMemoAmount = refundAmount - sumOfMdfAndCp;
                                creditMemo.CreditMemoStartDate      = DateTime.Now;
                                creditMemo.CreditMemoEndDate        = DateTime.Now.AddYears(1);
                                creditMemo.IsActive    = true;
                                creditMemo.UpdatedId   = CurrentUserId;
                                creditMemo.UpdatedDate = DateTime.Now;

                                // Approved
                                creditMemoPayout.ApprovalStatus = (int)CConstValue.ApprovalStatus.Approved;
                                creditMemoPayout.ApprovalDate   = DateTime.Now;
                                creditMemoPayout.ApprovalId     = CurrentUserId;
                                creditMemoPayout.Amount         = refundAmount;
                                creditMemoPayout.PayoutMethod   = vwRefund.PayoutMethod;
                                creditMemoPayout.IsActive       = true;

                                creditMemoPayout.UpdatedId   = CurrentUserId;
                                creditMemoPayout.UpdatedDate = DateTime.Now;

                                cCreditMemoPayout.Update(creditMemoPayout);

                                if (cCreditMemo.Update(creditMemo))
                                {
                                    var cInvoiceInfo = new CInvoice();
                                    var invoiceInfo  = cInvoiceInfo.Get(refundInfo.InvoiceId);

                                    var cOriginalInvoiceInfo = new CInvoice();
                                    var originalInvoiceInfo  = cOriginalInvoiceInfo.Get(Convert.ToInt32(invoiceInfo.OriginalInvoiceId));

                                    invoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Invoiced; // Invoiced
                                    invoiceInfo.UpdatedId = CurrentUserId;

                                    originalInvoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Cancelled_RF; // Canceled_RF
                                    originalInvoiceInfo.UpdatedId = CurrentUserId;

                                    var startDate = DateTime.Now;
                                    var endDate   = DateTime.Now;

                                    //invoice status update
                                    if (cInvoiceInfo.Update(invoiceInfo) && cOriginalInvoiceInfo.Update(originalInvoiceInfo))
                                    {
                                        // Program
                                        if (invoiceInfo.ProgramRegistrationId != null)
                                        {
                                            var cProgramRegiInfo = new CProgramRegistration();
                                            var programRegiInfo  = cProgramRegiInfo.Get(Convert.ToInt32(invoiceInfo.ProgramRegistrationId));
                                            programRegiInfo.UpdatedId               = CurrentUserId;
                                            programRegiInfo.UpdatedDate             = DateTime.Now;
                                            programRegiInfo.ProgramRegistrationType = 12; // cancel

                                            cProgramRegiInfo.Update(programRegiInfo);

                                            startDate = programRegiInfo.StartDate.Value;
                                            endDate   = programRegiInfo.EndDate.Value;
                                        }
                                        // Homestay
                                        else if (invoiceInfo.HomestayRegistrationId != null)
                                        {
                                            var cHomestayStudentRequest = new CHomestayStudentRequest();
                                            var homestayStudentRequest  = cHomestayStudentRequest.GetHomestayStudentRequest(Convert.ToInt32(invoiceInfo.HomestayRegistrationId));
                                            homestayStudentRequest.UpdateUserId          = CurrentUserId;
                                            homestayStudentRequest.UpdatedDate           = DateTime.Now;
                                            homestayStudentRequest.HomestayStudentStatus = 1; // cancel

                                            cHomestayStudentRequest.Update(homestayStudentRequest);

                                            startDate = homestayStudentRequest.StartDate.Value;
                                            endDate   = homestayStudentRequest.EndDate.Value;
                                        }
                                        // Dormitory
                                        else if (invoiceInfo.DormitoryRegistrationId != null)
                                        {
                                            var cDormitoryStudentRequest = new CDormitoryRegistrations();
                                            var dormitoryStudentRequest  = cDormitoryStudentRequest.GetDormitoryStudentRequest(Convert.ToInt32(invoiceInfo.ProgramRegistrationId));
                                            dormitoryStudentRequest.DormitoryStudentStatus = 1; // cancel
                                            dormitoryStudentRequest.UpdatedId   = CurrentUserId;
                                            dormitoryStudentRequest.UpdatedDate = DateTime.Now;

                                            cDormitoryStudentRequest.Update(dormitoryStudentRequest);

                                            startDate = dormitoryStudentRequest.StartDate.Value;
                                            endDate   = dormitoryStudentRequest.EndDate.Value;
                                        }

                                        // Rev
                                        var cInterimInvoice = new CInvoice();
                                        var interimInvoice  = new Invoice();
                                        CGlobal.Copy(invoiceInfo, interimInvoice);
                                        interimInvoice.OriginalInvoiceId = invoiceInfo.InvoiceId;
                                        interimInvoice.InvoiceType       = (int)CConstValue.InvoiceType.Refund_RV;
                                        interimInvoice.Status            = (int)CConstValue.InvoiceStatus.Invoiced;
                                        interimInvoice.CreatedId         = CurrentUserId;
                                        interimInvoice.CreatedDate       = DateTime.Now;

                                        if (cInterimInvoice.Add(interimInvoice) > 0)
                                        {
                                            var totalDays   = Convert.ToDateTime(endDate) - Convert.ToDateTime(startDate);
                                            var interimDays = Convert.ToDateTime(endDate) - Convert.ToDateTime(refundInfo.RefundDate);
                                            var interimRate = Math.Round((interimDays.TotalDays / totalDays.TotalDays), 2) * 100;

                                            var cInvoiceItem = new CInvoiceItem();
                                            var cOriginalInvoiceItemModels     = cInvoiceItem.GetInvoiceItemModels(invoiceInfo.InvoiceId);
                                            List <InvoiceItem> newInvoiceItems = new List <InvoiceItem>();
                                            foreach (CInvoiceItemModel ori in cOriginalInvoiceItemModels)
                                            {
                                                if (ori.InvoiceCoaItem.RevenueRecognition == 1)
                                                {
                                                    var newInvoiceRevItem = new InvoiceItem();
                                                    CGlobal.Copy(ori.InvoiceItem, newInvoiceRevItem);
                                                    newInvoiceRevItem.InvoiceId = interimInvoice.InvoiceId;

                                                    newInvoiceRevItem.StandardPrice *= (decimal)interimRate;
                                                    newInvoiceRevItem.StudentPrice  *= (decimal)interimRate;
                                                    newInvoiceRevItem.AgencyPrice   *= (decimal)interimRate;

                                                    newInvoiceRevItem.CreatedId   = CurrentUserId;
                                                    newInvoiceRevItem.CreatedDate = DateTime.Now;
                                                    newInvoiceRevItem.Remark      = "Refund Rev";
                                                    newInvoiceItems.Add(newInvoiceRevItem);
                                                }
                                            }

                                            if (newInvoiceItems.Count > 0)
                                            {
                                                // copy invoiceItems
                                                if (cInvoiceItem.Add(newInvoiceItems))
                                                {
                                                    RunClientScript("Close();");
                                                }
                                                else
                                                {
                                                    ShowMessage("failed to update inqury (Refund Ref Invoice Item)");
                                                }
                                            }
                                            else
                                            {
                                                RunClientScript("Close();");
                                            }
                                        }
                                        else
                                        {
                                            ShowMessage("failed to update inqury (Refund Ref Invoice)");
                                        }
                                    }
                                    else
                                    {
                                        ShowMessage("failed to update inqury (Original Invoice and Refund Invoice)");
                                    }
                                }
                                else
                                {
                                    ShowMessage("failed to update inqury (CreditMemo Info)");
                                }
                            }
                            else
                            {
                                RunClientScript("Close();");
                            }
                        }
                        else
                        {
                            ShowMessage("failed to update inqury (Refund Info)");
                        }
                    }
                    // Agency
                    else if (type == (int)CConstValue.Approval.Agency)
                    {
                        try
                        {
                            var cAgency = new CAgency();
                            var agency  = cAgency.Get(id);

                            idNumber              = agency.AgencyNumber;
                            agency.ApprovalDate   = approvalHistory.ApprovalDate;
                            agency.ApprovalId     = approvalHistory.ApprovalUser;
                            agency.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            agency.ApprovalStatus = approvalHistory.ApprovalStep;

                            cAgency.Update(agency);

                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // BusinessTrip
                    else if (type == (int)CConstValue.Approval.BusinessTrip)
                    {
                        try
                        {
                            var cBusinessTrip = new CBusinessTrip();
                            var businessTrip  = cBusinessTrip.Get(id);

                            businessTrip.ApprovalDate   = approvalHistory.ApprovalDate;
                            businessTrip.ApprovalId     = approvalHistory.ApprovalUser;
                            businessTrip.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            businessTrip.ApprovalStatus = approvalHistory.ApprovalStep;

                            cBusinessTrip.Update(businessTrip);

                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Purchase Order
                    else if (type == (int)CConstValue.Approval.PurchaseOrder)
                    {
                        try
                        {
                            var cPurchaseOrder = new CPurchaseOrder();
                            var purchaseOrder  = cPurchaseOrder.Get(id);

                            purchaseOrder.ApprovalDate   = approvalHistory.ApprovalDate;
                            purchaseOrder.ApprovalId     = approvalHistory.ApprovalUser;
                            purchaseOrder.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            purchaseOrder.ApprovalStatus = approvalHistory.ApprovalStep;

                            cPurchaseOrder.Update(purchaseOrder);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Package Program
                    else if (type == (int)CConstValue.Approval.Package)
                    {
                        try
                        {
                            var cP             = new CPackageProgram();
                            var packageProgram = cP.GetPackageProgram(id);

                            packageProgram.ApprovalDate   = approvalHistory.ApprovalDate;
                            packageProgram.ApprovalId     = approvalHistory.ApprovalUser;
                            packageProgram.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            packageProgram.ApprovalStatus = approvalHistory.ApprovalStep;
                            if (packageProgram.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                packageProgram.IsActive = true;
                            }

                            cP.Update(packageProgram);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    //Scholarship//
                    else if (type == (int)CConstValue.Approval.Scholarship)
                    {
                        try
                        {
                            var cScholar = new CScholarship();
                            var scholar  = cScholar.Get(Convert.ToInt32(id));

                            idNumber               = scholar.ScholarshipMasterNo;
                            scholar.ApprovalDate   = approvalHistory.ApprovalDate;
                            scholar.ApprovalId     = approvalHistory.ApprovalUser;
                            scholar.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            scholar.ApprovalStatus = approvalHistory.ApprovalStep;
                            if (scholar.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                scholar.IsActive = true;
                            }

                            cScholar.Update(scholar);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    //Promotion//
                    else if (type == (int)CConstValue.Approval.Promotion)
                    {
                        try
                        {
                            var cPromo = new CPromotion();
                            var promo  = cPromo.Get(Convert.ToInt32(id));

                            idNumber             = promo.PromotionMasterNo;
                            promo.ApprovalDate   = approvalHistory.ApprovalDate;
                            promo.ApprovalId     = approvalHistory.ApprovalUser;
                            promo.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            promo.ApprovalStatus = approvalHistory.ApprovalStep;
                            if (promo.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                promo.IsActive = true;
                            }

                            cPromo.Update(promo);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Expense Program
                    else if (type == (int)CConstValue.Approval.Expense)
                    {
                        try
                        {
                            var cExpense = new CExpense();
                            var expense  = cExpense.Get(id);

                            expense.ApprovalDate   = approvalHistory.ApprovalDate;
                            expense.ApprovalId     = approvalHistory.ApprovalUser;
                            expense.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            expense.ApprovalStatus = approvalHistory.ApprovalStep;

                            cExpense.Update(expense);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Hire
                    else if (type == (int)CConstValue.Approval.Hire)
                    {
                        try
                        {
                            var cHire = new CHire();
                            var hire  = cHire.Get(id);

                            hire.ApprovalDate   = approvalHistory.ApprovalDate;
                            hire.ApprovalId     = approvalHistory.ApprovalUser;
                            hire.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            hire.ApprovalStatus = approvalHistory.ApprovalStep;

                            cHire.Update(hire);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Vacation
                    else if (type == (int)CConstValue.Approval.Vacation)
                    {
                        try
                        {
                            var cVacationDetail = new CVacation();
                            var vacation        = cVacationDetail.Get(id);

                            vacation.ApprovalDate   = approvalHistory.ApprovalDate;
                            vacation.ApprovalId     = approvalHistory.ApprovalUser;
                            vacation.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            vacation.ApprovalStatus = approvalHistory.ApprovalStep;

                            cVacationDetail.Update(vacation);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // CreditMemoPayout
                    else if (type == (int)CConstValue.Approval.CreditMemoPayout)
                    {
                        try
                        {
                            var cCreditMemo = new CCreditMemoPayout();
                            var creditMemo  = cCreditMemo.Get(id);

                            creditMemo.ApprovalDate   = approvalHistory.ApprovalDate;
                            creditMemo.ApprovalId     = approvalHistory.ApprovalUser;
                            creditMemo.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            creditMemo.ApprovalStatus = approvalHistory.ApprovalStep;

                            cCreditMemo.Update(creditMemo);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }


                    if (approvalHistory.ApprovalStep != (int)CConstValue.ApprovalStatus.Approved) //if has a next approver, request approve
                    {
                        var approvalInfo = new CApproval();
                        var supervisor   = approvalInfo.GetSupuervisor(type, CurrentUserId);

                        if (supervisor > 0)
                        {
                            var cNextApprove = new CApprovalHistory();
                            var nextApprove  = cNextApprove.Get(type, id, supervisor);

                            nextApprove.IsApprovalRequest = true;
                            cNextApprove.Update(nextApprove);
                        }

                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToApproveUserAndRequestUser, id, idNumber, CurrentUserId);
                    }
                    // approved
                    else
                    {
                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToRequestUser, id, idNumber, CurrentUserId);
                    }
                }
            }
        }
Пример #13
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "Revise" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    try
                    {
                        var type = Convert.ToInt32(hfType.Value);
                        var id   = Convert.ToInt32(hfId.Value);

                        var cApprovalHistory = new CApprovalHistory();
                        var approvalHistory  = cApprovalHistory.Get(type, id, CurrentUserId);
                        approvalHistory.ApprovalDate = DateTime.Now;
                        approvalHistory.ApprovalMemo = tbRemark.Text;
                        // Revice
                        approvalHistory.ApprovalStep = (int)CConstValue.ApprovalStatus.Revise;

                        if (type == (int)CConstValue.Approval.Refund)
                        {
                            var cC = new CRefund();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Agency)
                        {
                            var cC = new CAgency();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.CorporateCreditCard)
                        {
                            var cC = new CCorporateCreditCard();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.BusinessTrip)
                        {
                            var cC = new CBusinessTrip();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Package)
                        {
                            var cC = new CPackageProgram();
                            var c  = cC.GetPackageProgram(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Expense)
                        {
                            var cC = new CExpense();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.PurchaseOrder)
                        {
                            var cC = new CPurchaseOrder();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Hire)
                        {
                            var cC = new CHire();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Vacation)
                        {
                            var cC = new CVacation();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Scholarship)
                        {
                            var cC = new CScholarship();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Promotion)
                        {
                            var cC = new CPromotion();
                            var c  = cC.Get(id);

                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.CreditMemoPayout)
                        {
                            var cC = new CCreditMemoPayout();
                            var c  = cC.Get(id);

                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }

                        // update approvalHistory
                        cApprovalHistory.Update(approvalHistory);

                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToRequestUser, id, string.Empty, CurrentUserId);

                        RunClientScript("Close();");
                    }
                    catch (Exception ex)
                    {
                        ShowMessage(ex.Message);
                    }
                }
            }
        }