public DataTable GetInvoiceData() { // student insurance var cStudent = new CStudent(); var student = cStudent.Get(Id); DataTable table = new DataTable(); table.Columns.Add("InvoiceCoaItemId", typeof(int)); table.Columns.Add("StandardPrice", typeof(decimal)); table.Columns.Add("StudentPrice", typeof(decimal)); table.Columns.Add("AgencyPrice", typeof(decimal)); table.Columns.Add("Remark", typeof(string)); table.Columns.Add("InvoiceItemId", typeof(int)); // Tuition if (tbPrgTuition.Value.ToString() != "0" && tbPrgTuition.Value.ToString() != string.Empty) { table.Rows.Add((int)CConstValue.InvoiceCoaItem.TuitionBasic, tbPrgStandardTuition.Value, tbPrgTuition.Value, tbPrgTuition.Value, string.Empty, 0); // Scholarship double scholarshipPrice = 0; ScholarshipId = null; ImageScholarshipSuccess.Visible = false; ImageScholarshipFail.Visible = true; RadNumericTextBoxAvailableScholarshipAmount.Text = string.Empty; RadNumericTextBoxAvailableScholarshipWeeks.Text = string.Empty; if (RadTextBoxScholarship.Text != string.Empty) { if (student != null && !string.IsNullOrEmpty(ddlAgency.SelectedValue)) { var cScholarship = new CScholarship(); var scholarship = cScholarship.GetScholarship(RadTextBoxScholarship.Text.Replace("-", string.Empty), student.SiteLocationId, Convert.ToInt32(ddlProgramWeeks.Text), Convert.ToInt32(ddlAgency.SelectedValue)); if (scholarship != null) { // search scholarship with availalble value over than 1 var vwScholarship = cScholarship.GetVwScholarship(scholarship.ScholarshipId); if (vwScholarship != null) { // if invoice doesn't have, it can be null decimal availableAmount = vwScholarship.AvailableAmount ?? 0; int availableWeeks = vwScholarship.AvailableWeeks ?? 0; if (scholarship.Amount != null) { RadNumericTextBoxAvailableScholarshipAmount.Value = (double)availableAmount; if (!string.IsNullOrEmpty(RadNumericTextBoxScholarshipAmount.Text)) { if ((double)availableAmount < RadNumericTextBoxScholarshipAmount.Value) { RadNumericTextBoxScholarshipAmount.Value = (double)availableAmount; } } else { RadNumericTextBoxScholarshipAmount.Value = (double)availableAmount; } scholarshipPrice = (double)RadNumericTextBoxScholarshipAmount.Value * -1; RadNumericTextBoxScholarshipWeeks.Text = string.Empty; RadButtonAvailableScholarshipAmount.Checked = true; RadButtonAvailableScholarshipWeeks.Checked = false; } else { RadNumericTextBoxAvailableScholarshipWeeks.Value = availableWeeks; if (!string.IsNullOrEmpty(RadNumericTextBoxScholarshipWeeks.Text)) { if ((double)availableWeeks < RadNumericTextBoxScholarshipWeeks.Value) { RadNumericTextBoxScholarshipWeeks.Value = (double)availableWeeks; } } else { RadNumericTextBoxScholarshipWeeks.Value = (double)availableWeeks; } // todo: cal week for scholarship. // cal weeks !!!!!!!!!!!!!!!!!! scholarshipPrice = (double)RadNumericTextBoxScholarshipWeeks.Value; RadNumericTextBoxScholarshipAmount.Value = scholarshipPrice; RadButtonAvailableScholarshipAmount.Checked = false; RadButtonAvailableScholarshipWeeks.Checked = true; } table.Rows.Add((int)CConstValue.InvoiceCoaItem.TuitionScholarship, 0, 0, scholarshipPrice, string.Empty, 0); ScholarshipId = scholarship.ScholarshipId; ImageScholarshipSuccess.Visible = true; ImageScholarshipFail.Visible = false; } } } } // Commission if (tbCommissionRate.Value.ToString() != "0" && tbCommissionRate.Value.ToString() != string.Empty) { table.Rows.Add((int)CConstValue.InvoiceCoaItem.CommissionTuition, 0, 0, (tbPrgTuition.Value + scholarshipPrice) * (tbCommissionRate.Value / -100), string.Empty, 0); } // Promotion PromotionId = null; ImagePromotionSuccess.Visible = false; ImagePromotionFail.Visible = true; if (RadTextBoxPromotion.Text != string.Empty) { if (student != null) { var cPromotion = new CPromotion(); var promotion = cPromotion.GetPromotion(RadTextBoxPromotion.Text, student.SiteLocationId); if (promotion != null) { PromotionId = promotion.PromotionId; ImagePromotionSuccess.Visible = true; ImagePromotionFail.Visible = false; } } } // from Other fee info if (!string.IsNullOrEmpty(ddlProgramName.SelectedValue)) { var cProgramOtherFeeInfo = new CProgramOtherFeeInfo(); var programOtherFeeInfo = cProgramOtherFeeInfo.Get(Convert.ToInt32(ddlProgramName.SelectedValue)); if (programOtherFeeInfo != null) { // other fees var regFee = programOtherFeeInfo.RegFee + programOtherFeeInfo.JRegFee; if (regFee > 0) { table.Rows.Add((int)CConstValue.InvoiceCoaItem.Registration, regFee, regFee, regFee, string.Empty, 0); } var materialFee = programOtherFeeInfo.AcademicFee + programOtherFeeInfo.MaterialFee + programOtherFeeInfo.UniformFee + programOtherFeeInfo.SupplyFee; if (materialFee > 0) { table.Rows.Add((int)CConstValue.InvoiceCoaItem.MaterialOthers, materialFee, materialFee, materialFee, string.Empty, 0); } var testFee = programOtherFeeInfo.TestFee + programOtherFeeInfo.ExamFee; if (testFee > 0) { table.Rows.Add((int)CConstValue.InvoiceCoaItem.TestExamFee, testFee, testFee, testFee, string.Empty, 0); } var internshipFee = programOtherFeeInfo.InternFee + programOtherFeeInfo.PracticeFee + programOtherFeeInfo.LCFee + programOtherFeeInfo.SDFee + programOtherFeeInfo.UPFee; if (internshipFee > 0) { table.Rows.Add((int)CConstValue.InvoiceCoaItem.InternshipBasic, internshipFee, internshipFee, internshipFee, string.Empty, 0); } var administration = programOtherFeeInfo.ACFee + programOtherFeeInfo.AdminFee + programOtherFeeInfo.UAGFee; if (administration > 0) { table.Rows.Add((int)CConstValue.InvoiceCoaItem.Administration, administration, administration, administration, string.Empty, 0); } var certificateFee = programOtherFeeInfo.CFee; if (certificateFee > 0) { table.Rows.Add((int)CConstValue.InvoiceCoaItem.ServiceCertificate, certificateFee, certificateFee, certificateFee, string.Empty, 0); } var otherFee = programOtherFeeInfo.OtherFee; if (otherFee > 0) { table.Rows.Add((int)CConstValue.InvoiceCoaItem.Other, otherFee, otherFee, otherFee, string.Empty, 0); } } } if (student != null) { if (student.Insurance) { // 33 table.Rows.Add((int)CConstValue.InvoiceCoaItem.Insurance, student.InsuranceTotal, student.InsuranceTotal, student.InsuranceTotal); } } // agency check if (string.IsNullOrEmpty(ddlAgency.SelectedValue)) { foreach (DataRow dr in table.Rows) { dr["AgencyPrice"] = 0; } } } return(table); }
protected void ToolbarClick(object sender, RadToolBarEventArgs e) { if (e.Item.Text == "New") { Grid.SelectedIndexes.Clear(); ResetForm(); } else if (e.Item.Text == "Save") { var cProg = new CProgram(); var prog = new Erp2016.Lib.Program(); if (string.IsNullOrEmpty(RadComboBoxProgramGroup.SelectedValue) == false) { prog.ProgramGroupId = Convert.ToInt32(RadComboBoxProgramGroup.SelectedValue); } prog.ProgramFullName = tbProgramFullName.Text; prog.ProgramWebName = tbProgramWebName.Text; prog.ProgramShortName = tbProgramShortName.Text; prog.ProgramDescription = tbDescript.Text; if (string.IsNullOrEmpty(ddlProgramType.SelectedValue) == false) { prog.ProgramType = Convert.ToInt32(ddlProgramType.SelectedValue); } else { prog.ProgramType = null; } if (string.IsNullOrEmpty(ddlComType.SelectedValue) == false) { prog.UisType = Convert.ToInt32(ddlComType.SelectedValue); } else { prog.UisType = null; } prog.EarningCredit = Convert.ToDecimal(tbEarningCredit.Value); //if (tbProgramWeek.Text != "") // prog.TotalWeeks = Convert.ToInt32(tbProgramWeek.Text); //else // prog.TotalWeeks = null; //if (tbProgramSemester.Text != "") // prog.TotalSemester = Convert.ToInt32(tbProgramSemester.Text); //else // prog.TotalSemester = null; //if (tbProgramMonth.Text != "") // prog.TotalMonth = Convert.ToInt32(tbProgramMonth.Text); //else // prog.TotalMonth = null; //if (tbProgramHoursDay.Text != "") // prog.HoursOfDay = Convert.ToInt32(tbProgramHoursDay.Text); //else // prog.HoursOfDay = null; //prog.HoursOfWeek = Convert.ToInt32(ddlHours.SelectedValue); prog.EstimatedStartDate = tbProgramStartDate.SelectedDate; prog.AdmissionRequirement = tbProgramAdmission.Text; prog.DiplomaCertificationRequirement = tbProgramDiploma.Text; if (string.IsNullOrEmpty(tbPracticum.Text) == false) { prog.PracticumWeeks = Convert.ToInt32(tbPracticum.Text); } else { prog.PracticumWeeks = null; } if (string.IsNullOrEmpty(tbIntership.Text) == false) { prog.IntershipWeeks = Convert.ToInt32(tbIntership.Text); } else { prog.IntershipWeeks = null; } prog.IsActive = RadButtonActive.Checked; prog.ActiveDate = tbProgramActiveDate.SelectedDate; prog.InActiveDate = tbProgramInActiveDate.SelectedDate; prog.CreatedId = CurrentUserId; prog.CreatedDate = DateTime.Now; prog.UpdatedId = CurrentUserId; prog.UpdatedDate = DateTime.Now; int programId = cProg.Add(prog); if (programId > 0) { var cProgramSiteLocation = new CProgramSiteLocation(); cProgramSiteLocation.DelProgramSiteLocationList(programId); foreach (var siteLocation in RadComboBoxSiteLocation.CheckedItems) { var programSiteLocation = new ProgramSiteLocation() { CreatedId = CurrentUserId, ProgramId = programId, SiteLocationId = Convert.ToInt32(siteLocation.Value), CreatedDate = DateTime.Now }; cProgramSiteLocation.Add(programSiteLocation); } // other info fee var cProgramOtherFeeInfo = new CProgramOtherFeeInfo(); var programOtherFeeInfo = new ProgramOtherFeeInfo(); for (var i = 1; i < 19; i++) { var fee = (RadNumericTextBox)RadPaneProgram.FindControl("tbFee" + i); programOtherFeeInfo.ProgramId = prog.ProgramId; decimal feeValue = (decimal)(fee.Value ?? 0); switch (i) { case 1: programOtherFeeInfo.RegFee = feeValue; //oid.InvoiceCoaItemId = 7; break; case 2: programOtherFeeInfo.JRegFee = feeValue; //oid.InvoiceCoaItemId = 7; break; case 3: programOtherFeeInfo.AcademicFee = feeValue; //oid.InvoiceCoaItemId = 11; break; case 4: programOtherFeeInfo.MaterialFee = feeValue; //oid.InvoiceCoaItemId = 11; break; case 5: programOtherFeeInfo.TestFee = feeValue; //oid.InvoiceCoaItemId = 31; break; case 6: programOtherFeeInfo.PracticeFee = feeValue; //oid.InvoiceCoaItemId = 27; break; case 7: programOtherFeeInfo.ExamFee = feeValue; //oid.InvoiceCoaItemId = 31; break; case 8: programOtherFeeInfo.AdminFee = feeValue; //oid.InvoiceCoaItemId = 13; break; case 9: programOtherFeeInfo.InternFee = feeValue; //oid.InvoiceCoaItemId = 27; break; case 10: programOtherFeeInfo.LCFee = feeValue; //oid.InvoiceCoaItemId = 27; break; case 11: programOtherFeeInfo.SDFee = feeValue; //oid.InvoiceCoaItemId = 27; break; case 12: programOtherFeeInfo.UPFee = feeValue; //oid.InvoiceCoaItemId = 27; break; case 13: programOtherFeeInfo.ACFee = feeValue; //oid.InvoiceCoaItemId = 13; break; case 14: programOtherFeeInfo.CFee = feeValue; //oid.InvoiceCoaItemId = 45; break; case 15: programOtherFeeInfo.SupplyFee = feeValue; //oid.InvoiceCoaItemId = 11; break; case 16: programOtherFeeInfo.UniformFee = feeValue; //oid.InvoiceCoaItemId = 11; break; case 17: programOtherFeeInfo.UAGFee = feeValue; //oid.InvoiceCoaItemId = 13; break; case 18: programOtherFeeInfo.OtherFee = feeValue; //oid.InvoiceCoaItemId = 0; break; } } programOtherFeeInfo.Comment = tbFeeComment.Text; programOtherFeeInfo.CreatedId = CurrentUserId; programOtherFeeInfo.CreatedDate = DateTime.Now; cProgramOtherFeeInfo.Add(programOtherFeeInfo); // other info var cOtid = new CProgramOtherInfo(); var otid = new ProgramOtherInfo(); otid.ProgramId = prog.ProgramId; otid.LocalCRC = tbLocalCRC.Text; otid.DoctorNote = tbDoctorNote.Text; otid.Noc = tbNoc.Text; otid.Hrsdc = tbHrsdc.Text; otid.Reference2 = tbReference2.Text; otid.Reference3 = tbReference3.Text; otid.Eng10 = tbEng10.Text; otid.Math10 = tbMath10.Text; otid.Sience11 = tbSience11.Text; otid.Eng12 = tbEng12.Text; otid.Bio12 = tbBio12.Text; otid.SSience = tbSSience.Text; otid.SMath = tbSMath.Text; otid.SEng = tbSEng.Text; otid.SLBio = tbSLBio.Text; otid.SLChemi = tbSLChemi.Text; otid.Immun = tbImmun.Text; otid.HelpB = tbHelpB.Text; otid.Comment = tbOthercomment.Text; otid.CreatedId = CurrentUserId; otid.CreatedDate = DateTime.Now; otid.UpdatedId = CurrentUserId; otid.UpdatedDate = otid.CreatedDate; if (cOtid.Add(otid) > 0) { ShowMessage("New program is added"); Grid.Rebind(); } } else { ShowMessage("Failed to add program, please try again"); } } else if (e.Item.Text == "Update") { if (Grid.SelectedValue != null) { var cProg = new CProgram(); var prog = cProg.Get(Convert.ToInt32(Grid.SelectedValue)); if (RadComboBoxProgramGroup.SelectedValue != null) { prog.ProgramGroupId = Convert.ToInt32(RadComboBoxProgramGroup.SelectedValue); } prog.ProgramFullName = tbProgramFullName.Text; prog.ProgramWebName = tbProgramWebName.Text; prog.ProgramShortName = tbProgramShortName.Text; prog.ProgramDescription = tbDescript.Text; if (ddlProgramType.SelectedValue != "") { prog.ProgramType = Convert.ToInt32(ddlProgramType.SelectedValue); } else { prog.ProgramType = null; } if (ddlComType.SelectedValue != "") { prog.UisType = Convert.ToInt32(ddlComType.SelectedValue); } else { prog.UisType = null; } prog.EarningCredit = Convert.ToDecimal(tbEarningCredit.Value); //if (tbProgramWeek.Text != "") // prog.TotalWeeks = Convert.ToInt32(tbProgramWeek.Text); //else // prog.TotalWeeks = null; //if (tbProgramSemester.Text != "") // prog.TotalSemester = Convert.ToInt32(tbProgramSemester.Text); //else // prog.TotalSemester = null; //if (tbProgramMonth.Text != "") // prog.TotalMonth = Convert.ToInt32(tbProgramMonth.Text); //else // prog.TotalMonth = null; //if (tbProgramHoursDay.Text != "") // prog.HoursOfDay = Convert.ToInt32(tbProgramHoursDay.Text); //else // prog.HoursOfDay = null; //prog.HoursOfWeek = Convert.ToInt32(ddlHours.SelectedValue); prog.EstimatedStartDate = tbProgramStartDate.SelectedDate; prog.AdmissionRequirement = tbProgramAdmission.Text; prog.DiplomaCertificationRequirement = tbProgramDiploma.Text; if (tbPracticum.Text != "") { prog.PracticumWeeks = Convert.ToInt32(tbPracticum.Text); } else { prog.PracticumWeeks = null; } if (tbIntership.Text != "") { prog.IntershipWeeks = Convert.ToInt32(tbIntership.Text); } else { prog.IntershipWeeks = null; } prog.IsActive = RadButtonActive.Checked; prog.ActiveDate = tbProgramActiveDate.SelectedDate; prog.InActiveDate = tbProgramInActiveDate.SelectedDate; prog.UpdatedId = CurrentUserId; prog.UpdatedDate = DateTime.Now; if (cProg.Update(prog)) { var cProgramSiteLocation = new CProgramSiteLocation(); cProgramSiteLocation.DelProgramSiteLocationList(prog.ProgramId); foreach (var siteLocation in RadComboBoxSiteLocation.CheckedItems) { var programSiteLocation = new ProgramSiteLocation() { CreatedId = CurrentUserId, ProgramId = prog.ProgramId, SiteLocationId = Convert.ToInt32(siteLocation.Value), CreatedDate = DateTime.Now }; cProgramSiteLocation.Add(programSiteLocation); } var cProgramOtherFeeInfo = new CProgramOtherFeeInfo(); var programOtherFeeInfo = cProgramOtherFeeInfo.Get(Convert.ToInt32(Grid.SelectedValue)); if (programOtherFeeInfo != null) { for (var i = 1; i < 19; i++) { var fee = (RadNumericTextBox)RadPaneProgram.FindControl("tbFee" + i); decimal feeValue = (decimal)(fee.Value ?? 0); switch (i) { case 1: programOtherFeeInfo.RegFee = feeValue; break; case 2: programOtherFeeInfo.JRegFee = feeValue; break; case 3: programOtherFeeInfo.AcademicFee = feeValue; break; case 4: programOtherFeeInfo.MaterialFee = feeValue; break; case 5: programOtherFeeInfo.TestFee = feeValue; break; case 6: programOtherFeeInfo.PracticeFee = feeValue; break; case 7: programOtherFeeInfo.ExamFee = feeValue; break; case 8: programOtherFeeInfo.AdminFee = feeValue; break; case 9: programOtherFeeInfo.InternFee = feeValue; break; case 10: programOtherFeeInfo.LCFee = feeValue; break; case 11: programOtherFeeInfo.SDFee = feeValue; break; case 12: programOtherFeeInfo.UPFee = feeValue; break; case 13: programOtherFeeInfo.ACFee = feeValue; break; case 14: programOtherFeeInfo.CFee = feeValue; break; case 15: programOtherFeeInfo.SupplyFee = feeValue; break; case 16: programOtherFeeInfo.UniformFee = feeValue; break; case 17: programOtherFeeInfo.UAGFee = feeValue; break; case 18: programOtherFeeInfo.OtherFee = feeValue; break; } } programOtherFeeInfo.Comment = tbFeeComment.Text; programOtherFeeInfo.UpdatedId = CurrentUserId; programOtherFeeInfo.UpdatedDate = DateTime.Now; cProgramOtherFeeInfo.Update(programOtherFeeInfo); } var cOtid = new CProgramOtherInfo(); var otid = cOtid.Get(Convert.ToInt32(Grid.SelectedValue)); if (otid != null) { otid.ProgramId = prog.ProgramId; otid.LocalCRC = tbLocalCRC.Text; otid.DoctorNote = tbDoctorNote.Text; otid.Noc = tbNoc.Text; otid.Hrsdc = tbHrsdc.Text; otid.Reference2 = tbReference2.Text; otid.Reference3 = tbReference3.Text; otid.Eng10 = tbEng10.Text; otid.Math10 = tbMath10.Text; otid.Sience11 = tbSience11.Text; otid.Eng12 = tbEng12.Text; otid.Bio12 = tbBio12.Text; otid.SSience = tbSSience.Text; otid.SMath = tbSMath.Text; otid.SEng = tbSEng.Text; otid.SLBio = tbSLBio.Text; otid.SLChemi = tbSLChemi.Text; otid.Immun = tbImmun.Text; otid.HelpB = tbHelpB.Text; otid.Comment = tbOthercomment.Text; otid.UpdatedId = CurrentUserId; otid.UpdatedDate = DateTime.Now; cOtid.Update(otid); } ShowMessage("Program updated"); RefreshProgramList(); } else { ShowMessage("Failed to update program, please try again"); } } } }