Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["Id"] != null)
        {
            int InvoiceId         = 0;
            var cDormitoryStudent = new CDormitoryRegistrations();
            InvoiceId = cDormitoryStudent.GetInvoiceIdbyDormitoryStudentId(Convert.ToInt32(Request["Id"]));


            // Payment
            _linqDataSourcePaymentHistory = PaymentHistoryGrid1.GetLinqDataSourcePaymentHistory();
            _radGridPaymentHistory        = PaymentHistoryGrid1.GetRadGridPaymentHistory();

            _linqDataSourcePaymentHistory.WhereParameters.Clear();
            _linqDataSourcePaymentHistory.WhereParameters.Add("InvoiceId", DbType.Int32, InvoiceId.ToString());
            //_linqDataSourcePaymentHistory.WhereParameters.Add("InvoiceId", DbType.Int32, "26367");
            _linqDataSourcePaymentHistory.Where = "InvoiceId == @InvoiceId";

            //Invoice Item
            _sqlDataSourceInvoiceItems = InvoiceItemGrid1.GetSqlDataSourceInvoiceItems();
            _radGridInvoiceItems       = InvoiceItemGrid1.GetRadGridInvoiceItems();
            // connect event of invoice Items.

            InvoiceItemGrid1.SetEditMode(false);
            _sqlDataSourceInvoiceItems.WhereParameters.Clear();

            _sqlDataSourceInvoiceItems.WhereParameters.Add("InvoiceId", DbType.Int32, InvoiceId.ToString());
            //_sqlDataSourceInvoiceItems.WhereParameters.Add("InvoiceId", DbType.Int32, "26367");

            _sqlDataSourceInvoiceItems.Where = "InvoiceId == @InvoiceId";
        }
    }
Example #2
0
    protected void ShowPlacementRequestDetail(int DormitoryRegistrationId)
    {
        var cHomestayStudentBasic     = new CDormitoryRegistrations();
        DormitoryRegistration Student = cHomestayStudentBasic.GetDormitoryStudentRequest(DormitoryRegistrationId);

        //Airpot Information

        ddl_pickup.SelectedValue           = Student.PickUp.ToString();
        DatePickArrivalDate.SelectedDate   = Student.ArrivalDate;
        TimePickerArrivalTime.SelectedTime = Student.ArriveTime;
        txtArrivalAirLine.Text             = Student.ArrivalAirLine;
        txtArrivalFlilghtNo.Text           = Student.ArrivalFlightNo;
        txtDepartingFrom.Text    = Student.DepartingFrom;
        ddlDropoff.SelectedValue = Student.DropOff.ToString();
        DatePicker_DepartureDate.SelectedDate = Student.DepartureDate;
        TimePickerDepartureTime.SelectedTime  = Student.DepartureTime;
        txtDepartureAirline.Text  = Student.DepartureAirLine;
        txtDepartureFlightNo.Text = Student.DepartureFlightNo;
        txtLeavingFrom.Text       = Student.LeavingFrom;



        //General Information
        DatePickerStartDate.SelectedDate = Student.StartDate;
        DatePickerEndDate.SelectedDate   = Student.EndDate;

        ddlExtention.SelectedValue = Student.ExtensionFlag.ToString();
        int Weeks    = Convert.ToInt32(Student.DormitoryWeeks);
        int ExtraDay = Convert.ToInt32(Student.ExtraDays);

        if (Weeks == 0)
        {
            TxtHomestayWeeks.Text = "";
        }
        else
        {
            TxtHomestayWeeks.Text = Weeks.ToString();
        }

        if (ExtraDay == 0)
        {
            TxtExtraDays.Text = "";
        }
        else
        {
            TxtExtraDays.Text = ExtraDay.ToString();
        }
        if (ExtraDay == 7)
        {
            Weeks = Weeks + 1;
            TxtHomestayWeeks.Text = Weeks.ToString();
            TxtExtraDays.Text     = "0";
        }
        ddlUrgent.SelectedValue = Student.UrgentRequest.ToString();

        txtComments.Text = Student.Comments;
        //File Upload
        file_upload.GetFileDownload(Convert.ToInt32(DormitoryRegistrationId));
        Dropdown_StudentlList(Convert.ToInt32(Student.StudentId)); // Load Student List
    }
Example #3
0
    protected DormitoryRegistration StudentRequest(int DormitoryRegistrationId)
    {
        var cDormitoryStudentRequest  = new CDormitoryRegistrations();
        DormitoryRegistration Student = cDormitoryStudentRequest.GetDormitoryStudentRequest(DormitoryRegistrationId);

        return(Student);
    }
Example #4
0
    protected void Dropdown_StudentlList(int DormitoryRegistrationId, int StudentId)
    {
        ddlStudent.Items.Clear();

        var cglobal        = new CGlobal();
        int SiteLocationId = CurrentSiteLocationId;

        if (StudentId > 0)
        {
            var cStudentRequest = new CDormitoryRegistrations();
            SiteLocationId = cStudentRequest.SiteLocationbyStudentId(StudentId);
        }
        ddlStudent.DataSource     = cglobal.LoadStudentList(SiteLocationId); //CurrentSiteLocationId
        ddlStudent.DataTextField  = "Name";
        ddlStudent.DataValueField = "Value";
        ddlStudent.Filter         = (RadComboBoxFilter)Convert.ToInt32(1);
        ddlStudent.Items.Insert(0, new RadComboBoxItem("", "0"));
        if (StudentId > 0)
        {
            ddlStudent.SelectedValue = StudentId.ToString();
        }
        else if (StudentId == 0 && DormitoryRegistrationId > 0)
        {
            ddlStudent.SelectedValue = GetStudentId(DormitoryRegistrationId).ToString();
        }
        else if (DormitoryRegistrationId == 0 && StudentId == 0)
        {
            ddlStudent.SelectedIndex = 0;
        }

        ddlStudent.DataBind();
    }
Example #5
0
    protected void Dropdown_StudentlList(int StudentId)
    {
        ddlStudent.Items.Clear();

        var cglobal = new CGlobal();

        int SiteLocationId = CurrentSiteLocationId;

        if (StudentId > 0)
        {
            var cStudentRequest = new CDormitoryRegistrations();
            SiteLocationId = cStudentRequest.SiteLocationbyStudentId(StudentId);
        }
        ddlStudent.DataSource     = cglobal.LoadStudentList(SiteLocationId);//CurrentSiteLocationId
        ddlStudent.DataTextField  = "Name";
        ddlStudent.DataValueField = "Value";
        if (StudentId == 0)
        {
            ddlStudent.SelectedIndex = 0;
        }
        else

        {
            ddlStudent.SelectedValue = StudentId.ToString();
        }

        ddlStudent.DataBind();
    }
Example #6
0
 protected void RadGridInvoice_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
 {
     if (Request["Id"] != null)
     {
         var cDormitoryStudent = new CDormitoryRegistrations();
         RadGridInvoice.DataSource = cDormitoryStudent.GetDormitoryInvoiceByRequestId(Convert.ToInt32(Request["Id"].ToString()));
     }
 }
Example #7
0
    protected void UpdateToolBar_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e)
    {
        if (DormitoryRegistrationId > 0)
        {
            if (UpdateToolBar.TabIndex == 0)
            {
                DormitoryRegistration Request = StudentRequest(DormitoryRegistrationId);
                int StudentId = Convert.ToInt32(Request.StudentId);
                if (Grid_HostList.SelectedValue != null)
                {
                    int HostId = Convert.ToInt32(Grid_HostList.SelectedValue);

                    if (Grid_HostRoom.SelectedValue != null)
                    {
                        int RoomId = Convert.ToInt32(Grid_HostRoom.SelectedValue);
                        if (Grid_HostBed.SelectedValue != null)
                        {
                            int BedId = Convert.ToInt32(Grid_HostBed.SelectedValue);
                            //Dormitory Placement

                            int AddResult                = 0;
                            var cDormitoryPlacement      = new CDormitoryPlacement();
                            DormitoryPlacement Placement = new DormitoryPlacement();
                            Placement.StudentBasicId    = DormitoryRegistrationId;
                            Placement.StudentId         = StudentId;
                            Placement.HostId            = HostId;
                            Placement.RoomId            = RoomId;
                            Placement.BedId             = BedId;
                            Placement.DormitoryAgencyId = 0;
                            Placement.StartDate         = Request.StartDate;
                            Placement.EndDate           = Request.EndDate;
                            Placement.PlacementStatus   = 1; //  Placed=1, Canceled =0, Schedule Change=2
                            Placement.PlacementType     = 1; // Placed by School=1, Place by Agency =2
                            Placement.CreatedDate       = DateTime.Now;
                            Placement.CreatedId         = CurrentUserId;
                            Placement.UpdatedDate       = DateTime.Now;
                            Placement.UpdatedId         = CurrentUserId;
                            AddResult = cDormitoryPlacement.Add(Placement);

                            if (AddResult > 0)
                            {
                                var cRequest = new CDormitoryRegistrations();

                                UpdateDormitoryStudentStatus(DormitoryRegistrationId, 2); //Placed By School
                                RunClientScript("Close();");
                                ShowMessage("Dormitory Placement Request has been placed successfully.");
                            }
                            else //Failed
                            {
                                ShowMessage("Failed to add Dormitory Placement Request, Please try it again.");
                            }
                        }
                    }
                }
            }
        }
    }
Example #8
0
    protected int GeDormitoryStudentId(int StudentId)
    {
        int result = 0;
        var cDormitoryStudentRequest = new CDormitoryRegistrations();

        int DormitoryRegistrationId = cDormitoryStudentRequest.GetCountDormitoryStudentRequestId(StudentId);

        result = DormitoryRegistrationId;
        return(result);
    }
Example #9
0
    protected int GetStudentId(int DormitoryRegistrationId)
    {
        int StudentId = 0;

        if (DormitoryRegistrationId > 0)
        {
            var cDormitoryStudent = new CDormitoryRegistrations();
            DormitoryRegistration StudentBasic = cDormitoryStudent.GetDormitoryStudentRequest(DormitoryRegistrationId);
            StudentId = Convert.ToInt32(StudentBasic.StudentId);
        }
        return(StudentId);
    }
Example #10
0
 protected void Grid_HostList_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
 {
     if (DormitoryRegistrationId > 0)
     {
         DormitoryRegistration Student = StudentRequest(DormitoryRegistrationId);
         DateTime StartDate            = Convert.ToDateTime(Student.StartDate);
         DateTime EndDate         = Convert.ToDateTime(Student.EndDate);
         var      cDormitoryBasic = new CDormitoryRegistrations();
         Grid_HostList.DataSource = cDormitoryBasic.DormitoryHostListWithVacantBed(CurrentSiteLocationId, StartDate, EndDate);
         //cDormitoryBasic.GetDormitoryHostActiveList(CurrentSiteLocationId, StartDate,EndDate);
     }
 }
Example #11
0
    protected void FillFormData(int DormitoryRegistrationId)
    {
        int type = Convert.ToInt32(Request["StudentId"].ToString()); // 0: New, 1000000:Schedule Change
        var cDormitoryStudentBasic    = new CDormitoryRegistrations();
        DormitoryRegistration Student = cDormitoryStudentBasic.GetDormitoryStudentRequest(DormitoryRegistrationId);

        //Airpot Information

        ddl_pickup.SelectedValue           = Student.PickUp.ToString();
        DatePickArrivalDate.SelectedDate   = Student.ArrivalDate;
        TimePickerArrivalTime.SelectedTime = Student.ArriveTime;
        txtArrivalAirLine.Text             = Student.ArrivalAirLine;
        txtArrivalFlilghtNo.Text           = Student.ArrivalFlightNo;
        txtDepartingFrom.Text    = Student.DepartingFrom;
        ddlDropoff.SelectedValue = Student.DropOff.ToString();
        DatePicker_DepartureDate.SelectedDate = Student.DepartureDate;
        TimePickerDepartureTime.SelectedTime  = Student.DepartureTime;
        txtDepartureAirline.Text  = Student.DepartureAirLine;
        txtDepartureFlightNo.Text = Student.DepartureFlightNo;
        txtLeavingFrom.Text       = Student.LeavingFrom;

        //General Information
        DatePickerStartDate.SelectedDate = Student.StartDate;
        DatePickerEndDate.SelectedDate   = Student.EndDate;

        ddlExtention.SelectedValue = Student.ExtensionFlag.ToString();
        int Weeks    = Convert.ToInt32(Student.DormitoryWeeks);
        int ExtraDay = Convert.ToInt32(Student.ExtraDays);

        if (Weeks == 0)
        {
            TxtDormitoryWeeks.Text = "";
        }
        else
        {
            TxtDormitoryWeeks.Text = Weeks.ToString();
        }

        if (ExtraDay == 0)
        {
            TxtExtraDays.Text = "";
        }
        else
        {
            TxtExtraDays.Text = ExtraDay.ToString();
        }
        ddlUrgent.SelectedValue = Student.UrgentRequest.ToString();

        txtComments.Text = Student.Comments;
        //File Upload
        file_upload.GetFileDownload(Convert.ToInt32(DormitoryRegistrationId));
        ddlStudent.Enabled = false;
    }
Example #12
0
    protected void Grid_HostBed_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        if (Grid_HostList.SelectedValue != null && Grid_HostRoom.SelectedValue != null)
        {
            var cDormitoryHostBed = new CDormitoryRegistrations();
            int hostid            = Convert.ToInt32(Grid_HostList.SelectedValue.ToString());
            int roomid            = Convert.ToInt32(Grid_HostRoom.SelectedValue.ToString());

            DormitoryRegistration Student = StudentRequest(DormitoryRegistrationId);
            Grid_HostBed.DataSource = cDormitoryHostBed.DormitoryBedListWithVacantBed(hostid, roomid, Convert.ToDateTime(Student.StartDate), Convert.ToDateTime(Student.EndDate));
            Grid_HostBed.Visible    = true;
        }
    }
Example #13
0
 protected void Grid_HostRoom_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
 {
     if (Grid_HostList.SelectedValue != null)
     {
         int hostId = 0;
         hostId = Convert.ToInt32(Grid_HostList.SelectedValue.ToString());
         List <DormitoryHostRoom> HostRoom = new List <DormitoryHostRoom>();
         var cDormitoryHostRoom            = new CDormitoryRegistrations();
         DormitoryRegistration Student     = StudentRequest(DormitoryRegistrationId);
         HostRoom = cDormitoryHostRoom.DormitoryRoomListWithVacantBed(hostId, Convert.ToDateTime(Student.StartDate), Convert.ToDateTime(Student.EndDate));
         Grid_HostRoom.DataSource = HostRoom;
     }
 }
Example #14
0
    protected void GridHistory_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        if (Grid_StudentList.SelectedValue != null)
        {
            int userid    = CurrentUserId;
            int StudentId = 0;
            int DormitoryRegistrationId = Convert.ToInt32(Grid_StudentList.SelectedValue);

            var cDormitoryStudent         = new CDormitoryRegistrations();
            DormitoryRegistration Student = cDormitoryStudent.GetDormitoryStudentRequest(DormitoryRegistrationId);
            StudentId = Convert.ToInt32(Student.StudentId);
            if (StudentId > 0)
            {
                GridHistory.DataSource = cDormitoryStudent.GetDormitoryStudentHistoryList(CurrentSiteLocationId, StudentId, DormitoryRegistrationId);
            }
        }
    }
Example #15
0
    public bool UpdateDormitoryStudentStatus(int DormitoryRegistrationId, int Status)
    {
        //Requested=1, Placed by School=2, Placed by Agency =3, Canceled =4,Schedule Changed=5
        bool updateStatus        = false;
        var  cDormitoryStudent   = new CDormitoryRegistrations();
        DormitoryRegistration HS = cDormitoryStudent.GetDormitoryStudentRequest(DormitoryRegistrationId);

        HS.DormitoryStudentStatus = Status;
        HS.UpdatedId   = CurrentUserId;
        HS.UpdatedDate = DateTime.Now;
        if (Status == 2 || Status == 3)
        {
            HS.PlacedUserId = CurrentUserId;
            HS.PlacedDate   = DateTime.Now;
        }
        updateStatus = cDormitoryStudent.Update(HS);

        return(updateStatus);
    }
Example #16
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);
                    }
                }
            }
        }
Example #17
0
    protected void UpdateStudentRegistar()
    {
        if (Request["id"] != null)
        {
            int DormitoryRegistrationId  = Id;
            var cDormitoryStudentRequest = new CDormitoryRegistrations();

            if (ScheduleChange == 0)
            {
                if (DormitoryRegistrationId == 0) //New Registrar
                {
                    int AddResult = 0;
                    DormitoryRegistration Student = new DormitoryRegistration();

                    //Retrive Data from Form
                    Student = GetFormData(Student);
                    //Dormitory Status
                    Student.DormitoryStudentStatus = 1; //Requested=1, Placed by School=2, Placed by Agency =3, Canceled =4
                    Student.CreatedDate            = DateTime.Now;
                    Student.CreatedId = CurrentUserId;
                    AddResult         = cDormitoryStudentRequest.Add(Student);
                    if (AddResult > 0)
                    {
                        file_upload.SaveFile(AddResult);
                        GenerateInvoice(AddResult, (int)CConstValue.InvoiceType.Dormitory);
                        RunClientScript("Close();");
                    }
                    else //Failed
                    {
                        ShowMessage("Failed to add a new dormitory registar, Please try it again.");
                    }
                }
                else //Update Registrar
                {
                    bool UpdateResult = false;
                    DormitoryRegistration UpdateStudent = cDormitoryStudentRequest.GetDormitoryStudentRequest(DormitoryRegistrationId);
                    // Retrive Data from From
                    UpdateStudent = GetFormData(UpdateStudent);

                    UpdateStudent.UpdatedId   = CurrentUserId;
                    UpdateStudent.UpdatedDate = DateTime.Now;
                    UpdateResult = cDormitoryStudentRequest.Update(UpdateStudent);
                    file_upload.SaveFile(UpdateStudent.DormitoryRegistrationId);

                    if (UpdateResult)
                    {
                        RunClientScript("Close();");
                        ShowMessage("Updated Dormitory Registration successfully.");
                    }
                    else //Failed
                    {
                        ShowMessage("Failed to update Dormitory Registration, please try it again.");
                    }
                }
            }
            else  //Schedule Change: New Dormitory Replacement Request
            {
                int SCResult = 0;
                DormitoryRegistration StudentBasic = new DormitoryRegistration();

                //Retrive Data from Form
                StudentBasic = GetFormData(StudentBasic);
                //Homestay Status
                StudentBasic.DormitoryStudentStatus = 1; //Requested=1, Placed by School=2, Placed by Agency =3, Canceled =4, Schedule Change=5
                StudentBasic.CreatedDate            = DateTime.Now;
                StudentBasic.CreatedId = CurrentUserId;
                SCResult = cDormitoryStudentRequest.Add(StudentBasic);
                if (SCResult > 0)
                {
                    file_upload.SaveFile(SCResult);
                    GenerateInvoice(SCResult, 14);// ScheduleChange
                    Grid_ChangeList.Rebind();
                    RunClientScript("Close();");
                    ShowMessage("Dormitory Schedule Change are added and Generated an invoice successfully.");
                }
                else //Failed
                {
                    ShowMessage("Failed to Add Schedule Change, Please try it again.");
                }
                //Wait for Jun's Schedule Change Invoice Function
                //Update Student Request Status: Schedule Change
                //Release Dormitory Placement (Host Bed)
            }
        }
    }
Example #18
0
    protected void Grid_StudentList_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        var cDormitoryStudent = new CDormitoryRegistrations();

        Grid_StudentList.DataSource = cDormitoryStudent.GetDormitoryStudentList(CurrentSiteLocationId);
    }
Example #19
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)");
                    }
                }
            }
        }
Example #20
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;
            }
        }
Example #21
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 startDate = DateTime.Today;
                        var endDate   = DateTime.Today;

                        // Program
                        if (original.ProgramRegistrationId != null)
                        {
                            var cProgramRegiInfo = new CProgramRegistration();
                            var programRegiInfo  = cProgramRegiInfo.Get(Convert.ToInt32(original.ProgramRegistrationId));

                            startDate = programRegiInfo.StartDate.Value;
                            endDate   = programRegiInfo.EndDate.Value;

                            programRegiInfo.StartDate   = RadDatePickerStartDate.SelectedDate.Value;
                            programRegiInfo.EndDate     = RadDatePickerEndDate.SelectedDate.Value;
                            programRegiInfo.UpdatedId   = CurrentUserId;
                            programRegiInfo.UpdatedDate = DateTime.Now;

                            cProgramRegiInfo.Update(programRegiInfo);
                        }
                        // Homestay
                        else if (original.HomestayRegistrationId != null)
                        {
                            var cHomestayStudentRequest = new CHomestayStudentRequest();
                            var homestayStudentRequest  = cHomestayStudentRequest.GetHomestayStudentRequest(Convert.ToInt32(original.HomestayRegistrationId));

                            startDate = homestayStudentRequest.StartDate.Value;
                            endDate   = homestayStudentRequest.EndDate.Value;

                            homestayStudentRequest.StartDate             = RadDatePickerStartDate.SelectedDate.Value;
                            homestayStudentRequest.EndDate               = RadDatePickerEndDate.SelectedDate.Value;
                            homestayStudentRequest.UpdateUserId          = CurrentUserId;
                            homestayStudentRequest.UpdatedDate           = DateTime.Now;
                            homestayStudentRequest.HomestayStudentStatus = 2;     // scheduel Change

                            cHomestayStudentRequest.Update(homestayStudentRequest);
                        }
                        // Dormitory
                        else if (original.DormitoryRegistrationId != null)
                        {
                            var cDormitoryStudentRequest = new CDormitoryRegistrations();
                            var dormitoryStudentRequest  = cDormitoryStudentRequest.GetDormitoryStudentRequest(Convert.ToInt32(original.DormitoryRegistrationId));

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

                            dormitoryStudentRequest.StartDate = RadDatePickerStartDate.SelectedDate.Value;
                            dormitoryStudentRequest.EndDate   = RadDatePickerEndDate.SelectedDate.Value;
                            dormitoryStudentRequest.DormitoryStudentStatus = 2;     // scheduel Change
                            dormitoryStudentRequest.UpdatedId   = CurrentUserId;
                            dormitoryStudentRequest.UpdatedDate = DateTime.Now;

                            cDormitoryStudentRequest.Update(dormitoryStudentRequest);
                        }

                        var cScheduleChange = new CScheduleChange();
                        var s = new ScheduleChange();

                        s.InvoiceId = original.InvoiceId;
                        s.ApplyDate = RadDatePickerApplyDate.SelectedDate.Value;
                        s.StartDate = startDate;
                        s.EndDate   = endDate;
                        s.Reason    = RadTextBoxReason.Text;
                        s.IsActive  = true;
                        s.CreatedId = CurrentUserId;

                        int scheduleChangeId = cScheduleChange.Add(s);
                        if (scheduleChangeId > 0)
                        {
                            // save uploading file
                            FileDownloadList1.SaveFile(scheduleChangeId);

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

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