protected void Page_Load(object sender, EventArgs e) { if (Request["Id"] != null) { int InvoiceId = 0; var cHomestayStudent = new CHomestayStudentRequest(); InvoiceId = cHomestayStudent.GetInvoiceIdbyHomestayStudentId(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"; } }
protected void ConfirmRequest(int HomestayStudentId) { var cHomestayStudentRequest = new CHomestayStudentRequest(); //Generate Invoice if there is no invoice number in invoice table //Status=1 as Requested }
protected HomestayStudentBasic StudentRequest(int HomestayStudentId) { var cHomestayStudentBasic = new CHomestayStudentRequest(); HomestayStudentBasic Student = cHomestayStudentBasic.GetHomestayStudentRequest(HomestayStudentId); return(Student); }
protected void RadGridInvoice_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { if (Request["Id"] != null) { var cStudentRequest = new CHomestayStudentRequest(); RadGridInvoice.DataSource = cStudentRequest.GetHomestayInvoiceByRequestId(Convert.ToInt32(Request["Id"].ToString())); } }
protected void UpdateToolBar_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e) { if (HomestayStudentId > 0) { if (UpdateToolBar.TabIndex == 0) { HomestayStudentBasic Request = StudentRequest(HomestayStudentId); 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); //Homestay Placement int AddResult = 0; var cHomestayPlacement = new CHomestayPlacement(); HomestayPlacement Placement = new HomestayPlacement(); Placement.StudentBasicId = HomestayStudentId; Placement.StudentId = StudentId; Placement.HostId = HostId; Placement.RoomId = RoomId; Placement.BedId = BedId; Placement.HomestayAgencyId = 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 = cHomestayPlacement.Add(Placement); if (AddResult > 0) { var cRequest = new CHomestayStudentRequest(); UpdateHomestayStudentStatus(HomestayStudentId, 2); //Placed By School RunClientScript("Close();"); ShowMessage("Homestay Placement Request has been placed successfully."); } else //Failed { ShowMessage("Failed to add Homestay Placement Request, Please try it again."); } } } } } } }
protected int GetHomestayStudentId(int StudentId) { int result = 0; var cHomestayStudentRequest = new CHomestayStudentRequest(); int HomestayStudentId = cHomestayStudentRequest.GetCountHomestayStudentRequestId(StudentId); result = HomestayStudentId; return(result); }
protected int GetStudentId(int HomestayStudentId) { int StudentId = 0; if (HomestayStudentId > 0) { var cHomestayStudent = new CHomestayStudentRequest(); HomestayStudentBasic StudentBasic = cHomestayStudent.GetHomestayStudentRequest(HomestayStudentId); StudentId = Convert.ToInt32(StudentBasic.StudentId); } return(StudentId); }
protected void GridHistory_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { if (Grid_StudentList.SelectedValue != null) { int userid = CurrentUserId; int StudentId = 0; int HomestayStudentId = Convert.ToInt32(Grid_StudentList.SelectedValue); var cHomestayStudent = new CHomestayStudentRequest(); HomestayStudentBasic Student = cHomestayStudent.GetHomestayStudentRequest(HomestayStudentId); StudentId = Convert.ToInt32(Student.StudentId); if (StudentId > 0) { GridHistory.DataSource = cHomestayStudent.GetHomestayStudentHistoryList(CurrentSiteLocationId, StudentId, HomestayStudentId); } } }
public bool UpdateHomestayStudentStatus(int HomestayStudentId, int Status) { //Requested=1, Placed by School=2, Placed by Agency =3, Canceled =6,Schedule Changed=5,Rejected 7 bool updateStatus = false; var cHomestayStudent = new CHomestayStudentRequest(); HomestayStudentBasic HS = cHomestayStudent.GetHomestayStudentRequest(HomestayStudentId); HS.HomestayStudentStatus = Status; HS.UpdateUserId = CurrentUserId; HS.UpdatedDate = DateTime.Now; if (Status == 2 || Status == 3) { HS.PlacedUserId = CurrentUserId; HS.PlacedDate = DateTime.Now; } updateStatus = cHomestayStudent.Update(HS); return(updateStatus); }
protected void ShowPlacementRequestDetail(int HomestayStudentId) { var cHomestayStudentBasic = new CHomestayStudentRequest(); HomestayStudentBasic Student = cHomestayStudentBasic.GetHomestayStudentRequest(HomestayStudentId); //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; //Preference ddlSmoking.SelectedValue = Student.Smoking.ToString(); ddlInternet.SelectedValue = Student.Internet.ToString(); ddlRoomType.SelectedValue = Student.RoomType.ToString(); ddlMealType.SelectedValue = Student.MealType.ToString(); ddlGuardian.SelectedValue = Student.GuardianRequired.ToString(); ddlPet.SelectedValue = Student.Pet.ToString(); ddlChildren.SelectedValue = Student.Children.ToString(); txtMedication.Text = Student.Medication; txtDiet.Text = Student.Diet; //General Information DatePickerStartDate.SelectedDate = Student.StartDate; DatePickerEndDate.SelectedDate = Student.EndDate; ddlExtention.SelectedValue = Student.ExtensionFlag.ToString(); int Weeks = Convert.ToInt32(Student.HomestayWeeks); 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(); ddlAllergy.SelectedValue = Student.AllergyType.ToString(); txtAllergyType.Text = Student.AllergyNote; txtComments.Text = Student.Comments; //File Upload file_upload.GetFileDownload(Convert.ToInt32(HomestayStudentId)); Dropdown_StudentlList(Convert.ToInt32(Student.StudentId)); // Load Student List }
protected void Grid_StudentList_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { var cHomestayStudent = new CHomestayStudentRequest(); Grid_StudentList.DataSource = cHomestayStudent.GetHomestayStudentList(CurrentUserId);//CurrentSiteLocationId }
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)"); } } } }
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; } }
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; } }
protected void UpdateStudentRegistar() { if (Request["id"] != null) { int HomestayStudentId = Id; var cHomestayStudentRequest = new CHomestayStudentRequest(); if (ScheduleChange == 0) { if (HomestayStudentId == 0) //New Registrar { int AddResult = 0; HomestayStudentBasic Student = new HomestayStudentBasic(); //Retrive Data from Form Student = GetFormData(Student); //Homestay Status Student.HomestayStudentStatus = 0; //Pending=0, Requested=1, Placed by School=2, Placed by Agency =3, Canceled =4 Student.CreatedDate = DateTime.Now; Student.CreatedUserId = CurrentUserId; AddResult = cHomestayStudentRequest.Add(Student); if (AddResult > 0) { file_upload.SaveFile(AddResult); // GenerateInvoice(AddResult, (int)CConstValue.InvoiceType.Homestay); RunClientScript("Close();"); ShowMessage("Added a new homestay registar and Generated an invoice successfully."); } else //Failed { ShowMessage("Failed to add a new homestay registar, Please try it again."); } } else //Update Registrar { bool UpdateResult = false; HomestayStudentBasic UpdateStudent = cHomestayStudentRequest.GetHomestayStudentRequest(HomestayStudentId); // Retrive Data from From UpdateStudent = GetFormData(UpdateStudent); UpdateStudent.HomestayStudentStatus = 1; //Requested UpdateStudent.UpdateUserId = CurrentUserId; UpdateStudent.UpdatedDate = DateTime.Now; UpdateResult = cHomestayStudentRequest.Update(UpdateStudent); int InvoiceId = 0; var cInvoice = new CInvoice(); InvoiceId = cInvoice.GetInvoiceIdbyHomestayStudentId(HomestayStudentId); if (InvoiceId == 0) { GenerateInvoice(HomestayStudentId, (int)CConstValue.InvoiceType.Homestay); //Generate Invoice } file_upload.SaveFile(UpdateStudent.HomestayStudentId); if (UpdateResult) { RunClientScript("Close();"); ShowMessage("Requested Homestay Registar successfully."); } else //Failed { ShowMessage("Failed to update Homestay Registrar, please try it again."); } } } else //Schedule Change: New Homestay Replacement Request { //int SCResult = 0; //HomestayStudentBasic StudentBasic = new HomestayStudentBasic(); ////Retrive Data from Form //StudentBasic = GetFormData(StudentBasic); ////Homestay Status //StudentBasic.HomestayStudentStatus = 1; //Requested=1, Placed by School=2, Placed by Agency =3, Canceled =4, Schedule Change=5 //StudentBasic.CreatedDate = DateTime.Now; //StudentBasic.CreatedUserId = CurrentUserId; //SCResult = cHomestayStudentRequest.Add(StudentBasic); //if (SCResult > 0) //{ // file_upload.SaveFile(SCResult); // GenerateInvoice(SCResult, 16); // var cHomestayCancleSheduleChange = new CHomestayCancelSheduleChange(); // HomestayCancelScheduleChange Cancel = new HomestayCancelScheduleChange(); // Cancel.CancellationDate = DateTime.MaxValue; // Cancel.Comment = txtScheduleComment.Text; // Cancel.ChangeType = 2; // 1=Cancel, 2=Schedule Change // Cancel.OriginalStudentBasicId = Convert.ToInt32(Request["Id"]); // Cancel.NewStudentBasicId = SCResult; // Cancel.RequestStatus = 0; //0=Pending, 1=Rejected, 2=Approved // Cancel.CreatedDate = DateTime.Now; // Cancel.CreatedId = CurrentUserId; // Cancel.UpdatedDate = DateTime.Now; // Cancel.UpdatedId = CurrentUserId; // int result = 0; // result = cHomestayCancleSheduleChange.Add(Cancel); // Grid_ChangeList.Rebind(); // ShowMessage("Homestay 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 Homestay Placement (Host Bed) } } }
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); } } } }