Exemplo n.º 1
0
        public ActionResult ProgramTransfer()
        {
            ProgramRegistration model = new ProgramRegistration();

            // use in development only
            model.TermOptions    = dao.GetAllTermOptions();
            model.ProgramOptions = dao.GetProgramOptions();
            return(View(model));
        }
Exemplo n.º 2
0
 public ActionResult TransferStudentProgram(ProgramRegistration model)
 {
     if (dao.TransferStudentToProgram(model.TermId, model.StudentId, model.ProgramId, model.CurrentSemester))
     {
         // transfer success
         return(RedirectToAction("Index"));
     }
     else
     {
         // transfer fail
         return(View("EditProgramRegistration", model));
     }
 }
Exemplo n.º 3
0
 public ActionResult CreateProgramRegistration(ProgramRegistration model)
 {
     if (dao.ProgramRegistrationNew(model.TermId, model.ProgramId, model.CurrentSemester, model.StudentId))
     {
         if (dao.CreateTranscript(model.StudentId))
         {
             return(View("Index"));
         }
     }
     model.TermOptions    = (List <TermOption>)Session["TermOptions"];
     model.ProgramOptions = (List <ProgramOption>)Session["ProgramOptions"];
     return(View(model));
 }
Exemplo n.º 4
0
        public ActionResult EditProgramRegistration(int StudentId, int ProgramId)
        {
            ProgramRegistration model = new ProgramRegistration();

            model.StudentId      = StudentId;
            model.ProgramId      = ProgramId;
            model.ProgramOptions = dao.GetProgramOptions();

            DateTime today    = DateTime.Today;
            DateTime fromDate = today.AddDays(-30);
            DateTime toDate   = today.AddMonths(5);

            model.TermOptions = dao.GetTermOptions(fromDate, toDate);

            Session["TermOptions"]    = model.TermOptions;
            Session["ProgramOptions"] = model.ProgramOptions;

            return(View(model));
        }
Exemplo n.º 5
0
        public ActionResult CreateProgramRegistration(int StudentId)
        {
            ProgramRegistration model = new ProgramRegistration();

            model.StudentId = StudentId;

            // Uncomment for production
            //DateTime today = DateTime.Today;
            //DateTime fromDate = today.AddDays(-30);
            //DateTime toDate = today.AddMonths(5);
            //model.TermOptions = dao.GetTermOptions(fromDate, toDate);

            model.TermOptions    = dao.GetAllTermOptions();
            model.ProgramOptions = dao.GetProgramOptions();

            Session["TermOptions"]    = model.TermOptions;
            Session["ProgramOptions"] = model.ProgramOptions;

            return(View(model));
        }
Exemplo n.º 6
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");
            }
        }
Exemplo n.º 7
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 programId        = Convert.ToInt32(ddlPackageProgram.SelectedValue.Split(',')[1]);
                    var packageProgramId = Convert.ToInt32(ddlPackageProgram.SelectedValue.Split(',')[0]);

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

                    programReg.StudentId        = Id;
                    programReg.ProgramId        = programId;
                    programReg.PackageProgramId = packageProgramId;

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

                    programReg.ProgramRegistrationType = 9;

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

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

                    if (proRegId > 0)
                    {
                        // add basic invoice first, then homestay or dormitory if exists.
                        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;
                        }
                        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 invoiceItems          = new List <InvoiceItem>();
                            var homestayInvoiceItems  = new List <InvoiceItem>();
                            var dormitoryInvoiceItems = new List <InvoiceItem>();
                            var airportInvoiceItems   = new List <InvoiceItem>();

                            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;

                                switch (invoiceItem.InvoiceCoaItemId)
                                {
                                case (int)CConstValue.InvoiceCoaItemForHomestay.HomestayBasic:
                                case (int)CConstValue.InvoiceCoaItemForHomestay.HomestayBasicDiscount:
                                case (int)CConstValue.InvoiceCoaItemForHomestay.HomestayPlacement:
                                case (int)CConstValue.InvoiceCoaItemForHomestay.HomestayPlacementDiscount:
                                case (int)CConstValue.InvoiceCoaItemForHomestay.HomestayInternetGuarantee:
                                case (int)CConstValue.InvoiceCoaItemForHomestay.HomestayOtherDiscount:
                                    homestayInvoiceItems.Add(invoiceItem);
                                    break;

                                case (int)CConstValue.InvoiceCoaItemForDormitory.DormitoryBasic:
                                case (int)CConstValue.InvoiceCoaItemForDormitory.DormitoryBasicDiscount:
                                case (int)CConstValue.InvoiceCoaItemForDormitory.DormitoryPlacement:
                                case (int)CConstValue.InvoiceCoaItemForDormitory.DormitoryPlacementDiscount:
                                case (int)CConstValue.InvoiceCoaItemForDormitory.DormitoryKeyDeposit:
                                case (int)CConstValue.InvoiceCoaItemForDormitory.DormitoryKeyDepositDiscount:
                                    dormitoryInvoiceItems.Add(invoiceItem);
                                    break;

                                case (int)CConstValue.InvoiceCoaItem.AirportPickup:
                                case (int)CConstValue.InvoiceCoaItem.AirportPickupDiscount:
                                case (int)CConstValue.InvoiceCoaItem.AirportDropoff:
                                case (int)CConstValue.InvoiceCoaItem.AirportDropoffDiscount:
                                case (int)CConstValue.InvoiceCoaItem.AirportPickupAndDropoff:
                                case (int)CConstValue.InvoiceCoaItem.AirportPickupAndDropoffDiscount:
                                    airportInvoiceItems.Add(invoiceItem);
                                    break;

                                default:
                                    invoiceItems.Add(invoiceItem);
                                    break;
                                }
                            }

                            // add invoiceItems except for homestay and dormitory
                            if (cInvoiceItem.Add(invoiceItems) == false)
                            {
                                ShowMessage("Error : add invoiceItem");
                            }

                            // add homestay if exist.
                            if (homestayInvoiceItems.Count > 0)
                            {
                                var newHomestayRegistrationId = new CHomestayStudentRequest().Add(new HomestayStudentBasic()
                                {
                                    HomestayStudentStatus = 0, // Pending
                                    StudentId             = Id,
                                    PlacedUserId          = 0,
                                    CreatedUserId         = CurrentUserId,
                                    CreatedDate           = DateTime.Now
                                });

                                if (newHomestayRegistrationId > 0)
                                {
                                    var invoiceForHomestay = new Invoice();
                                    invoiceForHomestay.HomestayRegistrationId = newHomestayRegistrationId;
                                    invoiceForHomestay.StudentId = Id;
                                    if (!string.IsNullOrEmpty(ddlAgency.SelectedValue))
                                    {
                                        invoiceForHomestay.AgencyId             = Convert.ToInt32(ddlAgency.SelectedValue);
                                        invoiceForHomestay.IsAgencySeasonalRate = RadButtonAgencyRateSeasonal.Checked;
                                        invoiceForHomestay.AgencyRate           = tbCommissionRate.Value;
                                    }
                                    invoiceForHomestay.SiteLocationId = CurrentSiteLocationId;
                                    invoiceForHomestay.InvoiceType    = (int)CConstValue.InvoiceType.Homestay;
                                    invoiceForHomestay.Status         = (int)CConstValue.InvoiceStatus.Pending;
                                    invoiceForHomestay.CreatedId      = CurrentUserId;
                                    invoiceForHomestay.CreatedDate    = DateTime.Now;

                                    var invoiceForHomestayId = cInvoice.Add(invoiceForHomestay);
                                    if (invoiceForHomestayId > 0)
                                    {
                                        foreach (var h in homestayInvoiceItems)
                                        {
                                            h.InvoiceId = invoiceForHomestayId;
                                        }
                                        foreach (var a in airportInvoiceItems)
                                        {
                                            a.InvoiceId = invoiceForHomestayId;
                                        }

                                        // merge between homestay Items and airport Items
                                        homestayInvoiceItems.AddRange(airportInvoiceItems);

                                        if (cInvoiceItem.Add(homestayInvoiceItems) == false)
                                        {
                                            ShowMessage("Error : add invoiceHomestayItem");
                                        }
                                    }
                                    else
                                    {
                                        ShowMessage("Error : add Homestay");
                                    }
                                }
                                else
                                {
                                    ShowMessage("Error : add Homestay registration");
                                }
                            }

                            // add dormitory if exist.
                            if (dormitoryInvoiceItems.Count > 0)
                            {
                                var newDormitoryRegistrationId = new CDormitoryRegistrations().Add(new DormitoryRegistration()
                                {
                                    DormitoryStudentStatus = 0, // Pending
                                    StudentId    = Id,
                                    PlacedUserId = 0,
                                    CreatedId    = CurrentUserId,
                                    CreatedDate  = DateTime.Now
                                });

                                if (newDormitoryRegistrationId > 0)
                                {
                                    var invoiceForDormitory = new Invoice();
                                    invoiceForDormitory.DormitoryRegistrationId = newDormitoryRegistrationId;
                                    invoiceForDormitory.StudentId = Id;
                                    if (!string.IsNullOrEmpty(ddlAgency.SelectedValue))
                                    {
                                        invoiceForDormitory.AgencyId             = Convert.ToInt32(ddlAgency.SelectedValue);
                                        invoiceForDormitory.IsAgencySeasonalRate = RadButtonAgencyRateSeasonal.Checked;
                                        invoiceForDormitory.AgencyRate           = tbCommissionRate.Value;
                                    }
                                    invoiceForDormitory.SiteLocationId = CurrentSiteLocationId;
                                    invoiceForDormitory.InvoiceType    = (int)CConstValue.InvoiceType.Dormitory;
                                    invoiceForDormitory.Status         = (int)CConstValue.InvoiceStatus.Pending;
                                    invoiceForDormitory.CreatedId      = CurrentUserId;
                                    invoiceForDormitory.CreatedDate    = DateTime.Now;

                                    var invoiceForDormitoryId = cInvoice.Add(invoiceForDormitory);
                                    if (invoiceForDormitoryId > 0)
                                    {
                                        foreach (var h in dormitoryInvoiceItems)
                                        {
                                            h.InvoiceId = invoiceForDormitoryId;
                                        }
                                        foreach (var a in airportInvoiceItems)
                                        {
                                            a.InvoiceId = invoiceForDormitoryId;
                                        }

                                        // merge between dormitory Items and airport Items
                                        dormitoryInvoiceItems.AddRange(airportInvoiceItems);

                                        if (cInvoiceItem.Add(dormitoryInvoiceItems) == false)
                                        {
                                            ShowMessage("Error : add invoiceDormitoryItem");
                                        }
                                    }
                                    else
                                    {
                                        ShowMessage("Error : add Dormitory");
                                    }
                                }
                                else
                                {
                                    ShowMessage("Error : add Dormitory registration");
                                }
                            }

                            RunClientScript("Close();");
                        }
                        else
                        {
                            ShowMessage("failed to update inqury (Invoice)");
                        }
                    }
                    else
                    {
                        ShowMessage("failed to update inqury (Program Registragion)");
                    }
                }
            }
        }
Exemplo n.º 8
0
        protected int NewProgramInvoiceCreate()
        {
            var cProgRegInfo = new CProgramRegistration();
            var programReg   = new ProgramRegistration();

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

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

            programReg.Weeks     = Convert.ToInt32(ddlProgramWeeks.SelectedValue);
            programReg.HrsStatus = Convert.ToInt32(ddlPrgHours.SelectedValue);

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

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

                invoice.ProgramRegistrationId = proRegId;
                invoice.StudentId             = 0;
                invoice.AgencyId = Convert.ToInt32(ddlAgency.SelectedValue);
                //invoice.ScholarshipId = Scholarship;
                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();
                //    var invoiceItem = new InvoiceItem();

                //    invoiceItem.InvoiceId = invoiceId;
                //    invoiceItem.InvoiceCoaItemId = 1; //1:Tuition
                //    invoiceItem.StandardPrice = Convert.ToDecimal(tbPrgStandardTuition.Value);
                //    invoiceItem.StudentPrice = Convert.ToDecimal(tbPrgTuition.Value);
                //    invoiceItem.AgencyPrice = Convert.ToDecimal(tbPrgTuition.Value);

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

                //    if (cInvoiceItem.Add(invoiceItem) > 0) //DB:InvoiceItem(Tuition Item)
                //    {
                //        var standardTuitionId = Convert.ToInt32(ViewState["ProgramTuitionId"]);
                //        var commission = Convert.ToDecimal(tbPrgTuition.Value) * Convert.ToDecimal(tbCommissionRate.Value) / 100;

                //        if (commission > 0)
                //        {
                //            cInvoiceItem.CommissionAdd(invoiceId, commission, CurrentUserId); //DB:InvoiceItem(Commission-Tuition)
                //        }

                //        if (cInvoiceItem.ItemsAdd(invoiceId, standardTuitionId, CurrentUserId))
                //        //DB:InvoiceItem(Other Items)
                //        {
                //            return invoiceId;
                //        }
                //        ShowMessage("failed to update inqury (Add Invoice Items)");
                //    }
                //    else
                //    {
                //        ShowMessage("failed to update inqury (Add Invoice Items)");
                //    }
                //}
                //else
                //{
                //    ShowMessage("failed to update inqury (Invoice)");
                //}
            }
            else
            {
                ShowMessage("failed to update inqury (Program Registragion)");
            }
            return(0);
        }