Ejemplo n.º 1
0
    protected void UpdateToolBar_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e)
    {
        if (HomestayStudentId > 0)
        {
            int Status = 0;
            switch (e.Item.Text)
            {
            case "Accepted":
                Status = 1;     //Accepted
                break;

            case "Cancelled:":
                Status = 0;     //Cancelled
                break;

            case "Rejected":
                Status = 3;     //Rejected
                break;

            default:
                Status = 0;
                break;
            }
            if (e.Item.Text != "Close Window")
            {
                HomestayStudentBasic Request = StudentRequest(HomestayStudentId);
                int StudentId = Convert.ToInt32(Request.StudentId);


                int AddResult               = 0;
                var cHomestayPlacement      = new CHomestayPlacement();
                HomestayPlacement Placement = new HomestayPlacement();
                Placement.StudentBasicId   = HomestayStudentId;
                Placement.StudentId        = StudentId;
                Placement.HostId           = 0;
                Placement.RoomId           = 0;
                Placement.BedId            = 0;
                Placement.HomestayAgencyId = 0;
                Placement.StartDate        = Request.StartDate;
                Placement.EndDate          = Request.EndDate;

                Placement.PlacementStatus = Status; //  Accepted=1, Canceled =0, Rejected:3, Schedule Change=2

                Placement.PlacementComment = txt_Comment.Text;
                Placement.PlacementType    = 2; // Placed by School=1, Place by Agency =2
                Placement.CreatedDate      = DateTime.Now;
                Placement.CreatedId        = CurrentUserId;
                Placement.UpdatedDate      = DateTime.Now;
                Placement.UpdatedId        = CurrentUserId;
                Placement.HomestayAgencyId = CurrentUserId;
                file_upload.GetFileDownload(Convert.ToInt32(HomestayStudentId));

                if (cHomestayPlacement.CountPlacementbyBasicId(HomestayStudentId) == 0)
                {
                    AddResult = cHomestayPlacement.Add(Placement);
                }
                else
                {
                    HomestayPlacement UpdatePlacement = cHomestayPlacement.GetByStudentBasicId(HomestayStudentId);
                    UpdatePlacement.PlacementStatus  = Status;
                    UpdatePlacement.PlacementComment = txt_Comment.Text;
                    UpdatePlacement.UpdatedDate      = DateTime.Now;
                    UpdatePlacement.UpdatedId        = CurrentUserId;
                    cHomestayPlacement.Update(UpdatePlacement);
                }


                file_upload.SaveFile(HomestayStudentId);
                // in HomestayBasic table
                int BasicStatus = 0;
                switch (Status)
                {
                case 0:
                    BasicStatus = 6;        // Cancelled by Agency
                    break;

                case 1:
                    BasicStatus = 3;         //Placed By Agency
                    break;

                case 3:
                    BasicStatus = 7;         //Rejected by Agency
                    break;

                default:
                    break;
                }
                UpdateHomestayStudentStatus(HomestayStudentId, BasicStatus);

                RunClientScript("Close();");
                ShowMessage("Homestay Placement Request has been updated successfully.");
            }
        }
    }
Ejemplo n.º 2
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)
                    {
                        var cBreak = new CBreak();
                        var b      = new Break();

                        b.InvoiceId      = original.InvoiceId;
                        b.BreakStartDate = RadDatePickerStartDate.SelectedDate.Value;
                        b.BreakEndDate   = RadDatePickerEndDate.SelectedDate.Value;

                        b.StartDate = RadDatePickerProgramStartDate.SelectedDate.Value;
                        b.EndDate   = RadDatePickerProgramEndDate.SelectedDate.Value;
                        b.Reason    = RadTextBoxReason.Text;
                        b.IsActive  = true;
                        b.CreatedId = CurrentUserId;

                        int breakId = cBreak.Add(b);
                        if (breakId > 0)
                        {
                            // save uploading file
                            FileDownloadList1.SaveFile(breakId);

                            // Program
                            if (original.ProgramRegistrationId != null)
                            {
                                var cProgramRegiInfo = new CProgramRegistration();
                                var programRegiInfo  = cProgramRegiInfo.Get(Convert.ToInt32(original.ProgramRegistrationId));
                                programRegiInfo.EndDate     = RadDatePickerProgramEndDate.SelectedDate.Value;
                                programRegiInfo.UpdatedId   = CurrentUserId;
                                programRegiInfo.UpdatedDate = DateTime.Now;

                                cProgramRegiInfo.Update(programRegiInfo);
                            }
                            // Homestay
                            else if (original.HomestayRegistrationId != null)
                            {
                                var cHomestayPlacement     = new CHomestayPlacement();
                                var homestayStudentRequest = cHomestayPlacement.GetByStudentBasicId(Convert.ToInt32(original.HomestayRegistrationId));
                                homestayStudentRequest.EndDate     = RadDatePickerProgramEndDate.SelectedDate.Value;
                                homestayStudentRequest.UpdatedId   = CurrentUserId;
                                homestayStudentRequest.UpdatedDate = DateTime.Now;

                                cHomestayPlacement.Update(homestayStudentRequest);
                            }
                            // Dormitory
                            else if (original.DormitoryRegistrationId != null)
                            {
                                var cDormitoryPlacement = new CDormitoryPlacement();
                                var dormitoryPlacement  = cDormitoryPlacement.GetByStudentBasicId(Convert.ToInt32(original.DormitoryRegistrationId));
                                dormitoryPlacement.EndDate     = RadDatePickerProgramEndDate.SelectedDate.Value;
                                dormitoryPlacement.UpdatedId   = CurrentUserId;
                                dormitoryPlacement.UpdatedDate = DateTime.Now;

                                cDormitoryPlacement.Update(dormitoryPlacement);
                            }

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

            case "Close":
                RunClientScript("Close();");
                break;
            }
        }