Ejemplo n.º 1
0
        protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            switch (e.Item.Text)
            {
            case "Save":
                if (IsValid)
                {
                    foreach (var chkItem in RadComboBoxMenu.CheckedItems)
                    {
                        var cInvoice = new CInvoice();
                        var invoice  = new Erp2016.Lib.Invoice();

                        invoice.StudentId = Convert.ToInt32(chkItem.Value);

                        invoice.Status         = (int)CConstValue.InvoiceStatus.Pending; // pending
                        invoice.SiteLocationId = CurrentSiteLocationId;
                        invoice.InvoiceType    = (int)CConstValue.InvoiceType.Simple;    //Simple Invoice(SI)

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

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

                        if (invoiceId > 0)
                        {
                            var cInvoiceItem = new CInvoiceItem();
                            var gridData     = InvoiceItemGrid1.GetGridData();
                            gridData = gridData.Insert(0, ",");
                            var gridDataRows = gridData.Split('|');
                            foreach (var gridDataRow in gridDataRows)
                            {
                                if (string.IsNullOrEmpty(gridDataRow))
                                {
                                    break;
                                }

                                var gridDataRowCell = gridDataRow.Split(',');

                                var invoiceCoaItem = gridDataRowCell[1];
                                var standardPrice  = gridDataRowCell[2];
                                var studentPrice   = gridDataRowCell[3];
                                var agencyPrice    = gridDataRowCell[4];
                                var remark         = gridDataRowCell[5];

                                var invoiceItem = new InvoiceItem();
                                invoiceItem.InvoiceId = invoiceId;
                                var cInvoiceCoaItem = new CInvoiceCoaItem();
                                invoiceItem.InvoiceCoaItemId = cInvoiceCoaItem.Get(invoiceCoaItem).InvoiceCoaItemId;
                                if (!string.IsNullOrEmpty(standardPrice))
                                {
                                    invoiceItem.StandardPrice = Convert.ToDecimal(standardPrice.Replace("$", string.Empty));
                                }
                                if (!string.IsNullOrEmpty(studentPrice))
                                {
                                    invoiceItem.StudentPrice = Convert.ToDecimal(studentPrice.Replace("$", string.Empty));
                                }
                                if (!string.IsNullOrEmpty(agencyPrice))
                                {
                                    invoiceItem.AgencyPrice = Convert.ToDecimal(agencyPrice.Replace("$", string.Empty));
                                }
                                invoiceItem.Remark = remark;

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

                                cInvoiceItem.Add(invoiceItem);
                            }
                        }
                    }
                    RunClientScript("Close();");
                }
                else
                {
                    ShowMessage("Error to add Simple Invoice");
                }
                break;

            case "Cancel":
                RunClientScript("Close();");
                break;
            }
        }
Ejemplo n.º 2
0
        protected void RadToolBarStudentContract_OnButtonClick(object sender, RadToolBarEventArgs e)
        {
            switch (e.Item.Text)
            {
            case "New Program":
                if (RadGridStudentList.SelectedValue != null)
                {
                    RunClientScript("ShowRegProgramNewWindow(" + RadGridStudentList.SelectedValue + ");");
                }
                break;

            case "New Package":
                if (RadGridStudentList.SelectedValue != null)
                {
                    RunClientScript("ShowRegPackageProgramNewWindow(" + RadGridStudentList.SelectedValue + ");");
                }
                break;

            case "New Manual Invoice":
                if (RadGridStudentList.SelectedValue != null)
                {
                    var cInvoice = new CInvoice();
                    var invoice  = new Erp2016.Lib.Invoice
                    {
                        StudentId      = Convert.ToInt32(RadGridStudentList.SelectedValue),
                        SiteLocationId = CurrentSiteLocationId,
                        InvoiceType    = (int)CConstValue.InvoiceType.Manual,    // manual invoice,
                        Status         = (int)CConstValue.InvoiceStatus.Pending, // pending
                        CreatedId      = CurrentUserId,
                        CreatedDate    = DateTime.Now
                    };

                    if (cInvoice.Add(invoice) > 0)
                    {
                        ShowMessage("Manual Invoice has been created.");
                    }
                    else
                    {
                        ShowMessage("Failed to insert inqury");
                    }

                    GetStudentContract();
                }
                break;

            case "New Homestay":
                if (RadGridStudentList.SelectedValue != null)
                {
                    RunClientScript("ShowNewHomestayNewWindow(0," + RadGridStudentList.SelectedValue + ",0);");
                }
                break;

            case "New Dormitory":
                if (RadGridStudentList.SelectedValue != null)
                {
                    RunClientScript("ShowNewDormitoryNewWindow(0," + RadGridStudentList.SelectedValue + ",0);");      // Modify Dormitory Request
                }
                break;

            case "View Invoice":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowInvoiceWindow(" + RadGridStudentContract.SelectedValue + ");");
                }
                break;

            case "Refund":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowRefundWindow(" + RadGridStudentContract.SelectedValue + ");");
                }
                break;

            case "Transfer":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowTransferWindow(" + RadGridStudentContract.SelectedValue + ");");
                }
                break;

            case "Break":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowBreakWindow(" + RadGridStudentContract.SelectedValue + ");");
                }
                break;

            case "Cancel":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowCancelWindow(" + RadGridStudentContract.SelectedValue + ");");
                }
                break;

            case "Program Change":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowProgramChangeWindow(" + RadGridStudentContract.SelectedValue + ");");
                }
                break;

            case "Schedule Change":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowScheduleChangeWindow(" + RadGridStudentContract.SelectedValue + ");");
                }
                break;

            // Schools
            case "Letter Of Acceptance":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridStudentContract.SelectedValue + "', '" + (int)CConstValue.Report.LetterOfAcceptance + "' );");
                }
                break;

            case "Letter Of Acceptance in table":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridStudentContract.SelectedValue + "', '" + (int)CConstValue.Report.LetterOfAcceptanceInTable + "' );");
                }
                break;

            case "Student Contract":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridStudentContract.SelectedValue + "', '" + (int)CConstValue.Report.StudentContract + "' );");
                }
                break;

            case "Orientation Form":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridStudentContract.SelectedValue + "', '" + (int)CConstValue.Report.OrientationForm + "' );");
                }
                break;

            case "Confirmation Of Completion Letter":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridStudentContract.SelectedValue + "', '" + (int)CConstValue.Report.ConfirmationOfCompletionLetter + "' );");
                }
                break;

            case "Confirmation Of Enrollment":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridStudentContract.SelectedValue + "', '" + (int)CConstValue.Report.ConfirmationOfEnrollment + "' );");
                }
                break;

            // Academy
            case "Certification":
                if (RadGridStudentContract.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridStudentContract.SelectedValue + "', '" + (int)CConstValue.Report.Certification + "' );");
                }
                break;
            }
        }
Ejemplo n.º 3
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.Invoiced_Hold;
                        original.UpdatedId = CurrentUserId;

                        if (cInvoice.Update(original))
                        {
                            var cRefundInvoice = new CInvoice();
                            var refundInvoice  = new Erp2016.Lib.Invoice();
                            CGlobal.Copy(original, refundInvoice);
                            refundInvoice.OriginalInvoiceId = original.InvoiceId;
                            switch (original.InvoiceType)
                            {
                            case (int)CConstValue.InvoiceType.General:
                            case (int)CConstValue.InvoiceType.Simple:
                            case (int)CConstValue.InvoiceType.Manual:
                                refundInvoice.InvoiceType = (int)CConstValue.InvoiceType.Refund_RF;
                                break;

                            case (int)CConstValue.InvoiceType.Homestay:
                                refundInvoice.InvoiceType = (int)CConstValue.InvoiceType.Refund_HR;
                                break;

                            case (int)CConstValue.InvoiceType.Dormitory:
                                refundInvoice.InvoiceType = (int)CConstValue.InvoiceType.Refund_DR;
                                break;
                            }
                            refundInvoice.Status      = (int)CConstValue.InvoiceStatus.Pending;
                            refundInvoice.CreatedId   = CurrentUserId;
                            refundInvoice.CreatedDate = DateTime.Now;

                            var invoiceId = cRefundInvoice.Add(refundInvoice);
                            if (invoiceId > 0)
                            {
                                var refundInvoiceItems = new CInvoiceItem();
                                refundInvoiceItems.RefundItemsUpdate(original.InvoiceId, invoiceId, Convert.ToDecimal(RefundInfo1.GetRefundRate().Value), CurrentUserId);

                                var cCreditMemo = new CCreditMemo();
                                var creditMemo  = new CreditMemo();

                                creditMemo.CreditMemoType           = (int)CConstValue.CreditMemoType.Refund;
                                creditMemo.InvoiceId                = invoiceId; //Refund Invoice Id
                                creditMemo.OriginalCreditMemoAmount = 0;
                                creditMemo.CreatedId                = CurrentUserId;
                                creditMemo.CreatedDate              = DateTime.Now;
                                creditMemo.IsActive = false;

                                var creditMemoId = cCreditMemo.Add(creditMemo);
                                if (creditMemoId > 0)
                                {
                                    var cCreditMemoPayout = new CCreditMemoPayout();
                                    var creditMemoPayout  = new CreditMemoPayout();

                                    creditMemoPayout.CreditMemoId = creditMemoId;
                                    creditMemoPayout.Amount       = 0;
                                    creditMemoPayout.IsActive     = false;
                                    creditMemoPayout.CreatedId    = CurrentUserId;
                                    creditMemoPayout.CreatedDate  = DateTime.Now;

                                    var creditMemoPayoutId = cCreditMemoPayout.Add(creditMemoPayout);
                                    if (creditMemoPayoutId > 0)
                                    {
                                        var cRefund = new CRefund();
                                        var refund  = new Refund();

                                        refund.CreditMemoPayoutId = creditMemoPayoutId;
                                        refund.InvoiceId          = invoiceId;
                                        refund.RefundDate         = Convert.ToDateTime(RefundInfo1.RadActualDate().SelectedDate);
                                        refund.RefundRate         = Convert.ToDouble(RefundInfo1.GetRefundRate().Value);
                                        refund.RefundReason       = RefundInfo1.GetReason().Text;
                                        refund.IsActive           = false;
                                        refund.CreatedId          = CurrentUserId;
                                        refund.CreatedDate        = DateTime.Now;

                                        if (cRefund.Add(refund) > 0)
                                        {
                                            // save uploading file
                                            FileDownloadList1.SaveFile(refund.RefundId);

                                            RunClientScript("Close();");
                                        }
                                        ShowMessage("failed to update inqury (Add Refund Info)");
                                    }
                                    else
                                    {
                                        ShowMessage("failed to update inqury (Add CreditMemoPayout)");
                                    }
                                }
                                else
                                {
                                    ShowMessage("failed to update inqury (Add CreditMemo)");
                                }
                            }
                            else
                            {
                                ShowMessage("failed to update inqury (Add Refund Invoice)");
                            }
                        }
                        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;
            }
        }
Ejemplo n.º 4
0
        protected void InvoiceToolbarButtonClicked(object sender, RadToolBarEventArgs e)
        {
            switch (e.Item.Text)
            {
            case "Confirm":
                if (RadGridInvoice.SelectedValue != null)
                {
                    var cInvoice = new CInvoice();
                    var invoice  = cInvoice.Get(Convert.ToInt32(RadGridInvoice.SelectedValue));
                    invoice.Status      = (int)CConstValue.InvoiceStatus.Invoiced; // Invoice Status(34) : Invoiced
                    invoice.UpdatedId   = CurrentUserId;
                    invoice.UpdatedDate = DateTime.Now;

                    if (cInvoice.Update(invoice))
                    {
                        ShowMessage("Update inquiry successfully");
                    }
                    else
                    {
                        ShowMessage("Failed to update inquiry");
                    }
                    e.Item.Enabled = false;
                    RadGridInvoice.Rebind();
                }
                break;

            case "Cancel":
                if (RadGridInvoice.SelectedValue != null)
                {
                    var cInvoice = new CInvoice();
                    var invoice  = cInvoice.Get(Convert.ToInt32(RadGridInvoice.SelectedValue));

                    if (invoice.Status == (int)CConstValue.InvoiceStatus.Pending)
                    {
                        RunClientScript("ShowCancelWindow(" + RadGridInvoice.SelectedValue + ");");
                    }
                    else if (invoice.Status == (int)CConstValue.InvoiceStatus.Invoiced)
                    {
                        if (new CPayment().InvoiceCheck(invoice.InvoiceId) == 0)
                        {
                            RunClientScript("ShowCancelWindow(" + RadGridInvoice.SelectedValue + ");");
                        }
                        else
                        {
                            ShowMessage("It can't because of already paid in invoice");
                        }
                    }
                    RadGridInvoice.Rebind();
                }
                break;

            case "Agency Invoice":
                if (RadGridInvoice.SelectedValue != null)
                {
                    var selectedInvoiceList = new List <int>();
                    foreach (GridDataItem item in RadGridInvoice.SelectedItems)
                    {
                        selectedInvoiceList.Add((int)item.GetDataKeyValue("InvoiceId"));
                    }

                    RunClientScript("ShowReportPop('" + String.Join(", ", selectedInvoiceList.ToArray()) + "', '" + (int)CConstValue.Report.InvoiceAgency + "' );");
                }
                break;

            case "Student Invoice":
                if (RadGridInvoice.SelectedValue != null)
                {
                    var selectedInvoiceList = new List <int>();
                    foreach (GridDataItem item in RadGridInvoice.SelectedItems)
                    {
                        selectedInvoiceList.Add((int)item.GetDataKeyValue("InvoiceId"));
                    }

                    RunClientScript("ShowReportPop('" + String.Join(", ", selectedInvoiceList.ToArray()) + "', '" + (int)CConstValue.Report.InvoiceStudent + "' );");
                }
                break;

            case "Modify":
                if (RadGridInvoice.SelectedValue != null)
                {
                    var cInvoice = new CInvoice();
                    var invoice  = cInvoice.Get(Convert.ToInt32(RadGridInvoice.SelectedValue));

                    if (invoice.Status == (int)CConstValue.InvoiceStatus.Invoiced ||
                        invoice.InvoiceType == (int)CConstValue.InvoiceType.General ||
                        invoice.InvoiceType == (int)CConstValue.InvoiceType.Simple ||
                        invoice.InvoiceType == (int)CConstValue.InvoiceType.Manual ||
                        invoice.InvoiceType == (int)CConstValue.InvoiceType.Homestay ||
                        invoice.InvoiceType == (int)CConstValue.InvoiceType.Dormitory)     //invoiced
                    {
                        var payments = new CPayment();

                        if (payments.InvoiceCheck(invoice.InvoiceId) == 0)
                        {
                            invoice.Status      = (int)CConstValue.InvoiceStatus.Cancelled_MD; // Invoice Status(34) : Cancelled_M
                            invoice.UpdatedId   = CurrentUserId;
                            invoice.UpdatedDate = DateTime.Now;

                            if (cInvoice.Update(invoice))
                            {
                                var cNewInvoice = new CInvoice();
                                var newInvoice  = new Erp2016.Lib.Invoice();
                                CGlobal.Copy(invoice, newInvoice);
                                newInvoice.OriginalInvoiceId = invoice.InvoiceId;
                                newInvoice.Status            = (int)CConstValue.InvoiceStatus.Pending; // pending
                                newInvoice.CreatedId         = CurrentUserId;
                                newInvoice.CreatedDate       = DateTime.Now;

                                if (cNewInvoice.Add(newInvoice) > 0)
                                {
                                    var cInvoiceItem = new CInvoiceItem();
                                    List <InvoiceItem> originalInvoiceItems = cInvoiceItem.GetInvoiceItems(invoice.InvoiceId);
                                    List <InvoiceItem> newInvoiceItems      = new List <InvoiceItem>();
                                    foreach (InvoiceItem ori in originalInvoiceItems)
                                    {
                                        var newInvoiceItem = new InvoiceItem();
                                        CGlobal.Copy(ori, newInvoiceItem);
                                        newInvoiceItem.InvoiceId   = newInvoice.InvoiceId;
                                        newInvoiceItem.CreatedId   = CurrentUserId;
                                        newInvoiceItem.CreatedDate = DateTime.Now;
                                        newInvoiceItems.Add(newInvoiceItem);
                                    }
                                    // copy invoiceItems
                                    if (cInvoiceItem.Add(newInvoiceItems) == false)
                                    {
                                        ShowMessage("Error inserting invoice Items");
                                    }

                                    RadGridInvoice.Rebind();
                                }
                            }
                        }
                        else
                        {
                            ShowMessage("It can't because of already paid in invoice");
                        }
                    }
                }
                break;

            case "New Simple Invoice":
                RunClientScript("ShowNewSimpleInvoice();");
                break;

            case "Student Page":
                if (RadGridInvoice.SelectedValue != null)
                {
                    Response.Redirect("~/Student?id=" + RadGridInvoice.SelectedValues["StudentId"]);
                }
                break;

            case "Payment Page":
                if (RadGridInvoice.SelectedValue != null)
                {
                    Response.Redirect("~/Payment?id=" + RadGridInvoice.SelectedValues["StudentId"]);
                }
                break;

            case "Deposit Page":
                if (RadGridInvoice.SelectedValue != null)
                {
                    Response.Redirect("~/Deposit?id=" + RadGridInvoice.SelectedValues["StudentId"]);
                }
                break;

            case "CreditMemo Page":
                if (RadGridInvoice.SelectedValue != null)
                {
                    Response.Redirect("~/CreditMemo?id=" + RadGridInvoice.SelectedValues["StudentId"]);
                }
                break;

            case "Refund Page":
                if (RadGridInvoice.SelectedValue != null)
                {
                    Response.Redirect("~/Refund?id=" + RadGridInvoice.SelectedValues["StudentId"]);
                }
                break;
            }
        }