
protected
void BtnExportar_Click(object sender, EventArgs e)
{
List<Festivo> listaFestivos = ....
//se crea un RadGrid vinculado a la lista de festivos.
RadGrid rg = new RadGrid();
//configuramos el radGrid para que tenga una sola columna
GridBoundColumn columnaFestivos = new GridBoundColumn();
columnaFestivos.UniqueName =
"Festivos";
columnaFestivos.DataField =
"Fecha";
columnaFestivos.HeaderText =
"Festivos";
rg.MasterTableView.Columns.Add(columnaFestivos);
rg.DataSource = listaFestivos;
rg.DataBind();
this.Exportar(rg);
}
private void ConfigureExport(RadGrid rg)
{
rg.ExportSettings.ExportOnlyData =
true;
rg.ExportSettings.HideStructureColumns =
true;
rg.ExportSettings.IgnorePaging =
true;
rg.ExportSettings.OpenInNewWindow =
true;
rg.Columns[0].Visible =
false;
}
public void Exportar(RadGrid rg)
{
ConfigureExport(rg);
rg.MasterTableView.ExportToExcel();
}
can you help me? thanks

when i add a asyncupload to my page, the scheduler will have display problem that the default skin cannot apply.
if i comment the related code (as follows), the scheduler can display properly.
<telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" OnClientFileUploaded="onClientFileUploaded" MultipleFileSelection="Automatic" InitialFileInputsCount="1" /><br /> <asp:Button runat="server" ID="buttonSubmit" OnClick="buttonSubmit_Click" Text="Submit" />i had walk through the code many times, but cannot find out the problem...
<%@ Page Title="" Language="VB" MasterPageFile="~/LRDB.master" AutoEventWireup="false" CodeFile="training_session_edit.aspx.vb" Inherits="training_session_edit" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <style type="text/css"> .style4 { text-decoration: underline; } .style10 { width: 278px; height: 15px; background-color: #E7EEF6; } html .RadDropDownList_Default .rddlDisabled { border-color: #cccccc; } </style> <script type="text/javascript"> function clientTransfering(sender, args) { args.set_cancel(true); var checkedNodes = args.get_sourceListBox().get_checkedItems(); for (var i in checkedNodes) { var item = checkedNodes[i]; args.get_sourceListBox().transferToDestination(item); } } function OnClientItemChecked(sender, args) { args.get_item().set_selected(true); // args.get_item().set_checked(true); } function ConfirmDelete(sender) { var callBackFn = function (args) { if (args) __doPostBack(sender.id.replace(/_/gi, '$'), ''); else return false; } radconfirm('Are you sure you want to delete this item?', callBackFn); } </script> <style type="text/css"> .configuratorPanel div.RadComboBox { float: left; margin-right: 5px; } .configuratorPanel div.RadComboBox table { display: table; } </style></asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"> <telerik:RadWindowManager runat="server" ID="rwm1"> </telerik:RadWindowManager> <script type="text/javascript"> var lastClickedItem = null; var clickCalledAfterRadprompt = false; var clickCalledAfterRadconfirm = false; function onClientButtonClicking(sender, args) { if (args.get_item().get_text() == "Confirm") { if (!clickCalledAfterRadconfirm) { args.set_cancel(true); lastClickedItem = args.get_item(); radconfirm("Are you sure you want to confirm?", confirmCallbackFunction); } } else if (args.get_item().get_text() == "Delete") { if (!clickCalledAfterRadconfirm) { args.set_cancel(true); lastClickedItem = args.get_item(); radconfirm("Are you sure you want to delete?", confirmCallbackFunction); } } } function confirmCallbackFunction(args) { if (args) { clickCalledAfterRadconfirm = true; lastClickedItem.click(); } else clickCalledAfterRadconfirm = false; lastClickedItem = null; } </script> <telerik:RadToolBar ID="rtbMenu" runat="server" Width="100%" Skin="Windows7" OnClientButtonClicking="onClientButtonClicking" OnButtonClick="rtbMenu_ButtonClick"> <Items> <telerik:RadToolBarButton Value="Edit" Text="Edit" Width="80px" /> <telerik:RadToolBarButton IsSeparator="true" /> <telerik:RadToolBarButton Value="Save" Text="Save" Width="80px" Enabled="false" /> <telerik:RadToolBarButton IsSeparator="true" /> <telerik:RadToolBarButton Value="Delete" Text="Delete" Width="80px" /> <telerik:RadToolBarButton IsSeparator="true" /> <telerik:RadToolBarButton Value="Confirm" Text="Confirm" Width="80px" /> <telerik:RadToolBarButton IsSeparator="true" /> <telerik:RadToolBarButton Value="Attendance" Text="Attendance" Width="100px" Enabled="false" /> <telerik:RadToolBarButton IsSeparator="true" /> <telerik:RadToolBarButton Value="Exam_Result" Text="Exam. Result" Width="100px" Enabled="false" /> <telerik:RadToolBarButton IsSeparator="true" /> <telerik:RadToolBarButton Value="Complete" Text="Complete" Width="80px" Enabled="false" /> <telerik:RadToolBarButton IsSeparator="true" /> <telerik:RadToolBarButton Value="Refresh" Text="Refresh" Width="80px" /> <telerik:RadToolBarButton IsSeparator="true" /> <telerik:RadToolBarButton Value="Back" Text="Back" Width="80px" CausesValidation="false"/> <telerik:RadToolBarButton Value="BackSeparator" IsSeparator="true" /> </Items> </telerik:RadToolBar> <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All" EnableRoundedCorners="true" /> <div class="div_menu"> <div id="content_function" class="content_function"> <telerik:RadFormDecorator ID="RpFormDecorator" runat="server" Skin="Windows7" DecoratedControls="All" EnableRoundedCorners="true" /> <div style="margin-left:5px;"> <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"> <table style="width:80%;"> <tr> <td align="left" valign="top" class="style10">Course </td> <td align="left" valign="top"> <telerik:RadDropDownList ID="rdl_select_course" runat="server" DefaultMessage="Please Select" AutoPostBack="True" OnSelectedIndexChanged="rdl_select_course_OnSelectedIndexChanged" DataSourceID="LDS_ddl_course" DataTextField="Course_Name" DataValueField="Course_ID" Enabled="false" > </telerik:RadDropDownList> <asp:LinqDataSource ID="LDS_ddl_course" runat="server" ContextTypeName="dcLRDBDataContext" EntityTypeName="" TableName="db_Courses"> </asp:LinqDataSource> <asp:Label ID="lb_msg" runat="server" Visible="false"></asp:Label> </td> </tr> <tr> <td align="left" valign="top" class="style10">Select Location </td> <td align="left" valign="top"> <telerik:RadDropDownList ID="rdl_select_location" runat="server" DefaultMessage="Please Select" Enabled="False" AutoPostBack="True" OnSelectedIndexChanged="rdl_select_location_OnSelectedIndexChanged" DataSourceID="LDS_ddl_location" DataTextField="Location" DataValueField="Location_ID" > </telerik:RadDropDownList> <asp:LinqDataSource ID="LDS_ddl_location" runat="server" ContextTypeName="dcLRDBDataContext" EntityTypeName="" TableName="db_Locations"> </asp:LinqDataSource> </td> </tr> <tr> <td align="left" valign="top" class="style10">Select Trainer </td> <td align="left" valign="top"> <telerik:RadDropDownList ID="rdl_select_trainer" runat="server" DefaultMessage="Please Select" Enabled="False" AutoPostBack="True" OnSelectedIndexChanged="rdl_select_trainer_OnSelectedIndexChanged" DataSourceID="ObjectDataSource1" DataTextField="DisplayName" DataValueField="Trainer_ID" > </telerik:RadDropDownList> <asp:Label ID="errmsg_ddl_trainer" runat="server" Visible="false" Text="No available Trainer for this Course and Location"></asp:Label> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetTrainerDetailsArrayByUserID" TypeName="LRDB"> <SelectParameters> <asp:SessionParameter Name="id" SessionField="AvailableTrainerID" Type="String" /> </SelectParameters> </asp:ObjectDataSource> </td> </tr> <tr> <td align="left" valign="top" class="style10">Selection Criteria </td> <td align="left" valign="top" class="style13"> <table> <tr> <td class="style15">> Employee </td> <td> <telerik:RadDropDownTree ID="rdl_select_employee" runat="server" DataSourceID="ODS_Employee" DataTextField="employee_display_name" DataValueField="employee_id" DefaultMessage="Please Select" AutoPostBack="True" CheckBoxes="SingleCheck" Width="250px" Enabled="false"> </telerik:RadDropDownTree> <asp:ObjectDataSource ID="ODS_Employee" runat="server" SelectMethod="GetEmployeeDetailsArrayBySessionIDProjectID" TypeName="LRDB"> <SelectParameters> <asp:QueryStringParameter Name="SID" QueryStringField="SessionID" Type="Int32" /> <asp:SessionParameter Name="PID" SessionField="SelectedPID" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> </td> </tr> <tr> <td class="style15">> Role Type</td> <td> <telerik:RadDropDownTree ID="rdl_select_roletype" runat="server" DataSourceID="LDS_roletype" DataTextField="rolename" DataValueField="roletypeid" DefaultMessage="Please Select" AutoPostBack="True" CheckBoxes="SingleCheck" Width="250px" Enabled="false"> </telerik:RadDropDownTree> <asp:ObjectDataSource ID="ODS_roletype" runat="server" SelectMethod="GetRoleTypeBySessionIDProjectID" TypeName="LRDB"> <SelectParameters> <asp:QueryStringParameter Name="SID" QueryStringField="SessionID" Type="Int32" /> <asp:SessionParameter Name="PID" SessionField="SelectedPID" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> <asp:LinqDataSource ID="LDS_roletype" runat="server" ContextTypeName="dcLRDBDataContext" EntityTypeName="" TableName="db_Dictionary_RoleTypes"> </asp:LinqDataSource> </td> </tr> <tr> <td class="style15">> Job Title </td> <td> <telerik:RadDropDownTree ID="rdl_select_jobtitle" runat="server" DataSourceID="LDS_JobTitle" DataTextField="job_title" DataValueField="id" DefaultMessage="Please Select" AutoPostBack="True" CheckBoxes="SingleCheck" Width="250px" Enabled="false"> </telerik:RadDropDownTree> <asp:ObjectDataSource ID="ODS_JobTitle" runat="server" SelectMethod="GetJobTitleBySessionIDProjectID" TypeName="LRDB"> <SelectParameters> <asp:QueryStringParameter Name="SID" QueryStringField="SessionID" Type="Int32" /> <asp:SessionParameter Name="PID" SessionField="SelectedPID" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> <asp:LinqDataSource ID="LDS_JobTitle" runat="server" ContextTypeName="dcLRDBDataContext" EntityTypeName="" TableName="db_Dictionary_Job_Titles"> </asp:LinqDataSource> </td> </tr> <tr> <td class="style15">> Department </td> <td> <telerik:RadDropDownTree ID="rdl_select_dept" runat="server" DataSourceID="LDS_Dept" DataTextField="department" DataValueField="deptid" DefaultMessage="Please Select" AutoPostBack="True" CheckBoxes="SingleCheck" Width="250px" Enabled="false"> </telerik:RadDropDownTree> <asp:ObjectDataSource ID="ODS_Dept" runat="server" SelectMethod="GetDeptBySessionIDProjectID" TypeName="LRDB"> <SelectParameters> <asp:QueryStringParameter Name="SID" QueryStringField="SessionID" Type="Int32" /> <asp:SessionParameter Name="PID" SessionField="SelectedPID" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> <asp:LinqDataSource ID="LDS_Dept" runat="server" ContextTypeName="dcLRDBDataContext" EntityTypeName="" TableName="db_Departments"> </asp:LinqDataSource> </td> </tr> </table><asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_click" Enabled="false"/> <br /> <br /> <br /> <br /> <table> <tr> <td> Unselect <br /> <telerik:RadListBox runat="server" ID="RadListBox_unselect" Height="200px" Width="230px" AllowTransfer="True" TransferToID="RadListBox_select" Enabled="false" AutoPostBack="True" CheckBoxes="True" SelectionMode="Multiple" style="top: 0px; left: 0px" DataSourceID="ODS_Unselect" OnClientItemChecked="OnClientItemChecked" DataTextField="employee_display_name" DataValueField="employee_id" OnClientTransferring="clientTransfering"> </telerik:RadListBox> <asp:ObjectDataSource ID="ODS_Unselect" runat="server" SelectMethod="GetEmployeeArrayByListBySessionID" TypeName="LRDB"> <SelectParameters> <asp:SessionParameter DefaultValue="0" Name="id" SessionField="EmpList" Type="String" /> <asp:QueryStringParameter Name="SID" QueryStringField="SessionID" Type="String" /> </SelectParameters> </asp:ObjectDataSource> </td> <td></td> <td> Selected <br /> <telerik:RadListBox runat="server" ID="RadListBox_select" Height="200px" Width="200px" TransferToID="RadListBox_unselect" Enabled="False" AutoPostBack="True" CheckBoxes="True" style="top: 0px; left: 0px" DataSourceID="ODS_SelectedEmployee" DataTextField="employee_display_name" DataValueField="employee_id"> </telerik:RadListBox> <asp:ObjectDataSource ID="ODS_SelectedEmployee" runat="server" SelectMethod="GetSelectedEmployeeArrayBySessionID" TypeName="LRDB"> <SelectParameters> <asp:QueryStringParameter Name="SID" QueryStringField="SessionID" Type="String" /> </SelectParameters> </asp:ObjectDataSource> </td> </tr> </table> </td> </tr> <tr> <td align="left" valign="top" class="style10">Teaching Material URL </td> <td align="left" valign="top"> <asp:TextBox ID="Tb_material_url" runat="server" Width="671px" Enabled="false"></asp:TextBox> <asp:HyperLink ID="hl_material_url" runat="server" Enabled="false" Target="_blank" Visible="false">Test URL</asp:HyperLink> </td> </tr> <tr> <td align="left" valign="top" class="style10">Attachment </td> <td align="left" valign="top"> <telerik:RadFormDecorator ID="RadFormDecoratorAttachment" runat="server" DecoratedControls="All" EnableRoundedCorners="false" /> <div> <telerik:RadAjaxManager ID="RadAjaxManagerAttachment" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanelAttachment"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="ListViewPanelAttachment"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="ListViewPanelAttachment"></telerik:AjaxUpdatedControl> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings> </telerik:RadAjaxManager> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanelAttachment" runat="server"> </telerik:RadAjaxLoadingPanel> <asp:Panel ID="ListViewPanelAttachment" runat="server" Enabled="false"> <telerik:RadListView ID="RadListViewAttachment" DataSourceID="LDS_Attachment" runat="server" Skin="Windows7" ItemPlaceholderID="AttachmentFileContainer" DataKeyNames="FileID" AllowPaging="true"> <LayoutTemplate> <fieldset style="width: 400px;" id="FieldSetAttachment"> <table cellpadding="0" cellspacing="0"><%-- <tr> <td> <asp:Button ID="Button1" runat="server" Text="Add new product" OnClick="AddNewButton_Click" Visible="<%# Not Container.IsItemInserted %>" CausesValidation="false"></asp:Button> </td> </tr>--%> <tr> <td> <asp:Panel ID="AttachmentFileContainer" runat="server"> </asp:Panel> </td> </tr><%-- <tr> <td> <telerik:RadDataPager ID="RadDataPagerAttachment" runat="server" PagedControlID="RadListViewAttachment" PageSize="5"> <Fields> <telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField> <telerik:RadDataPagerButtonField FieldType="Numeric"></telerik:RadDataPagerButtonField> <telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField> </Fields> </telerik:RadDataPager> </td> </tr>--%> </table> </fieldset> </LayoutTemplate> <ItemTemplate> <fieldset style="float: left; width: 360px;"> <table cellpadding="0" cellspacing="0" style="height: 100%;"> <tr> <td style="width: 20%;"> File Name: </td> <td style="width: 80%; padding-left: 5px;"> <%# Eval("FileName")%> </td> </tr> <tr> <td> Description: </td> <td style="width: 80%; padding-left: 5px;"> <%# Eval("Description")%> </td> </tr> <tr> <td> Upload Date: </td> <td style="width: 80%; padding-left: 5px;"> <%# Eval("UploadDate") %> </td> </tr> <tr> <td colspan="2"> <asp:Button ID="Button1" runat="server" CommandName="Edit" Text="Edit" CausesValidation="false"> </asp:Button> <asp:Button ID="Button2" runat="server" CommandName="Delete" OnClientClick="ConfirmDelete(this); return false;" Text="Delete"></asp:Button> </td> </tr> </table> </fieldset> </ItemTemplate> <EditItemTemplate> <fieldset style="float: left; width: 360px; height: 180px;"> <table cellpadding="0" cellspacing="0" style="height: 100%"> <tr> <td style="width: 20%;"> Description: </td> <td style="width: 80%; padding-left: 5px;"> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Description") %>' Width="120px"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="TextBox1"></asp:RequiredFieldValidator> </td> </tr> <tr> <td colspan="2"> <asp:Button ID="Button1" runat="server" CommandName="Update" Text="Update"></asp:Button> <asp:Button ID="Button2" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false"> </asp:Button> </td> </tr> </table> </fieldset> </EditItemTemplate> </telerik:RadListView> <div class="uploaded-files"> <asp:Literal runat="server" ID="ltrNoResults" Visible="True" Text="<strong>No files uploaded</strong>" /> <asp:Repeater runat="server" ID="Repeater1"> <HeaderTemplate><ul></HeaderTemplate> <FooterTemplate></ul></FooterTemplate> <ItemTemplate> <li> <dl> <dt>File Description:</dt> <dd><%# DirectCast(Container.DataItem, Telerik.Web.UI.UploadedFile).GetFieldValue("Description").ToString()%></dd> <dt>File name:</dt> <dd><%# DataBinder.Eval(Container.DataItem, "FileName").ToString() %></dd> <dt>File size:</dt> <dd><%# DataBinder.Eval(Container.DataItem, "ContentLength").ToString() %></dd> </dl> </li> </ItemTemplate> </asp:Repeater> </div> <telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" OnClientFileUploaded="onClientFileUploaded" MultipleFileSelection="Automatic" InitialFileInputsCount="1" /> <br /> <asp:Button runat="server" ID="buttonSubmit" OnClick="buttonSubmit_Click" Text="Submit" /> <script src="../js/UploadScript.js" type="text/javascript"></script> </asp:Panel> <asp:LinqDataSource ID="LDS_Attachment" runat="server" ContextTypeName="dcLRDBDataContext" EntityTypeName="" TableName="db_Attachments" Where="SessionID == @SessionID" EnableUpdate="true" EnableInsert="true" EnableDelete="true" > <WhereParameters> <asp:QueryStringParameter DefaultValue="0" Name="SessionID" QueryStringField="SessionID" Type="Int32" /> </WhereParameters> </asp:LinqDataSource> <telerik:RadWindowManager ID="RadWindowManagerAttachment" runat="server"> </telerik:RadWindowManager> </div> </td> </tr> <tr> <td align="left" valign="top" class="style10">Select Date & Time </td> <td align="left" valign="top"> <telerik:RadAjaxLoadingPanel runat="server" ID="RadAjaxLoadingPanel1" InitialDelayTime="200"> </telerik:RadAjaxLoadingPanel> <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1"> <script type="text/javascript"> //<![CDATA[ var selectedAppointment = null; var contextMenuSlot = null; function checkResourceMenuItem(menu, appointment) { var calendar = appointment.get_resources().getResourcesByType("Calendar").getResource(0); if (!calendar) return; var categorizeItem = menu.findItemByText("Categorize"); //Traverse all menu items below "Categorize" for (var i = 0; i < categorizeItem.get_items().get_count(); i++) { var item = categorizeItem.get_items().getItem(i); if (item.get_value() == calendar.get_key()) { //The item corresponds to the current "Calendar" - the Value of the item stores the Key of the resource item.set_imageUrl("Images/checked.gif"); } else { item.set_imageUrl(""); } } } //Called when the user right-clicks an appointment function appointmentContextMenu(sender, eventArgs) { var menu = $find("<%= SchedulerAppointmentContextMenu.ClientID %>"); selectedAppointment = eventArgs.get_appointment(); checkResourceMenuItem(menu, selectedAppointment); menu.show(eventArgs.get_domEvent()); } </script> </telerik:RadScriptBlock> <telerik:RadScheduler runat="server" ID="RadScheduler1" Width="748px" Skin="Windows7" DataEndField="End_Time" DataKeyField="Session_ID" DataRecurrenceParentKeyField="RecurrenceParentId" DataRecurrenceField="RecurrenceRule" DataSourceID="LDS_schedule" DataStartField="Start_Time" DataSubjectField="db_Course.Course_Name" OnClientAppointmentContextMenu="appointmentContextMenu" OnAppointmentDelete="RadScheduler1_AppointmentDelete" OnAppointmentDataBound="RadScheduler1_DataBound" OnAppointmentInsert="RadScheduler1_AppointmentInsert" OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" StartEditingInAdvancedForm="true" StartInsertingInAdvancedForm="false" AllowInsert="true" Enabled="false"> <AdvancedForm Modal="true"></AdvancedForm> <AppointmentContextMenus> <%--The appointment context menu interaction is handled on the client in this example--%> <%--See the JavaScript code above--%> <telerik:RadSchedulerContextMenu runat="server" ID="SchedulerAppointmentContextMenu"> <Items> <telerik:RadMenuItem Text="Open" Value="CommandEdit" Enabled="false" Visible="false"> </telerik:RadMenuItem><%-- <telerik:RadMenuItem IsSeparator="True"> </telerik:RadMenuItem> <telerik:RadMenuItem IsSeparator="True"> </telerik:RadMenuItem>--%> </Items> </telerik:RadSchedulerContextMenu> </AppointmentContextMenus> </telerik:RadScheduler> <%-- Where="Parent_ID == @Session_ID && Project_ID == @Project_ID">--%> <asp:LinqDataSource ID="LDS_schedule" runat="server" ContextTypeName="dcLRDBDataContext" EntityTypeName="" TableName="db_Training_Sessions" Where="Project_ID == @Project_ID"> <WhereParameters> <asp:QueryStringParameter Name="Session_ID" QueryStringField="SessionID" Type="Int32" /> <asp:SessionParameter Name="Project_ID" SessionField="SelectedPID" Type="Int32" /> </WhereParameters> </asp:LinqDataSource> </td> </tr> </table> </telerik:RadAjaxPanel> </div> </div> </div></asp:Content>Code behind
Imports Telerik.Web.UIPartial Class training_session_edit Inherits System.Web.UI.Page Dim CourseID As Integer Dim errMsg As String = "" Dim overlapMsg As String = "" Dim isOverlap As Boolean = False Private Property b As Object Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then Dim lb_panel As Label lb_panel = CType(Master.FindControl("lb_panel"), Label) lb_panel.Text = lb_panel.Text.Replace("Course", "Session") If Request.QueryString("SessionID") <> "" Then Dim dc As New dcLRDBDataContext Dim result = (From cs In dc.db_Training_Sessions Where cs.Session_ID = Request.QueryString("SessionID").ToString And cs.Parent_ID Is Nothing).FirstOrDefault If Not IsNothing(result) Then rdl_select_course.SelectedValue = result.Course_ID.ToString rdl_select_location.SelectedValue = result.Location_ID.ToString rdl_select_trainer.SelectedValue = result.Trainer_ID.ToString CourseID = result.Course_ID.ToString Tb_material_url.Text = result.MaterialURL If Tb_material_url.Text <> "" Then hl_material_url.NavigateUrl = Tb_material_url.Text 'hl_material_url.Enabled = True End If Session.Remove("SessionStatus") Session.Remove("EmpList") HttpContext.Current.Session("SessionStatus") = result.status If HttpContext.Current.Session("SessionStatus") = "Confirmed" Then rtbMenu.FindItemByValue("Confirm").Enabled = False 'rtbMenu.FindItemByValue("Delete").Enabled = False rtbMenu.FindItemByValue("Exam_Result").Enabled = True rtbMenu.FindItemByValue("Attendance").Enabled = True End If If HttpContext.Current.Session("SessionStatus") = "Completed" Then rtbMenu.FindItemByValue("Confirm").Enabled = False rtbMenu.FindItemByValue("Edit").Enabled = False rtbMenu.FindItemByValue("Delete").Enabled = False End If Session.Remove("AvailableTrainerID") Session.Remove("SelectedTrainerID") If Not IsNothing(result.Location_ID) And Not IsNothing(result.Course_ID) Then HttpContext.Current.Session("AvailableTrainerID") = GetAvailableTrainerIDByLocationIDCourseID(result.Location_ID, result.Course_ID) End If If IsNothing(result.Location_ID) And Not IsNothing(result.Trainer_ID) Then HttpContext.Current.Session("AvailableTrainerID") = GetUserIDbyTrainerID(result.Trainer_ID.ToString) HttpContext.Current.Session("SelectedTrainerID") = GetUserIDbyTrainerID(result.Trainer_ID.ToString) End If End If RadScheduler1.AllowDelete = False RadScheduler1.AllowEdit = False RadScheduler1.AllowInsert = False End If End If End Sub 'Protected Sub RadToolBar1_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) ' If e.Item.Text = "Run radprompt" Then ' Label1.Text = e.Item.Value ' Else ' Label1.Text = DateTime.Now.ToString() ' End If 'End Sub Protected Sub rtbMenu_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtbMenu.ButtonClick Dim dc As New dcLRDBDataContext Dim result = (From cs In dc.db_Training_Sessions Where cs.Session_ID = Request.QueryString("SessionID").ToString).FirstOrDefault If Not IsNothing(result) Then CourseID = result.Course_ID End If If e.Item.Value = "Go" Then Response.Redirect("~/TrainingAdmin/training_session_create.aspx") ElseIf e.Item.Value = "Refresh" Then Response.Redirect("~/TrainingAdmin/training_session_edit.aspx?SessionID=" & Request.QueryString("SessionID")) ElseIf e.Item.Value = "Attendance" Then Response.Redirect("~/TrainingAdmin/training_attendance_records_edit.aspx?SessionID=" & Request.QueryString("SessionID")) ElseIf e.Item.Value = "Complete" Then CompleteTraining() Response.Redirect("~/TrainingAdmin/training_session_edit.aspx?SessionID=" & Request.QueryString("SessionID")) ElseIf e.Item.Value = "Exam_Result" Then Response.Redirect("~/TrainingAdmin/training_exam_records_edit.aspx?SessionID=" & Request.QueryString("SessionID")) ElseIf e.Item.Value = "Confirm" Then If RadListBox_select.Items.Count = 0 Then Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('You had not selected any Employee for the training.');", True) 'ElseIf Tb_material_url.Text = "" Then ' Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('You had not input Teaching Material URL.');", True) Else If CheckSessionExist() = True Then If ConfirmTraining() = True Then If isOverlap = True Then errMsg = "The following employee had overlap session with other training. cannot be enroll." & overlapMsg Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('" & errMsg & "');", True) End If Response.Redirect("~/TrainingAdmin/training_session.aspx?CourseID=" & CourseID) Else Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('" & errMsg & "');", True) End If Else Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('You had not create time slot for the training.');", True) End If End If ElseIf e.Item.Value = "Delete" Then DeleteRecords() 'if course had been confirmed If HttpContext.Current.Session("SessionStatus") = "Confirmed" Then End If Response.Redirect("~/TrainingAdmin/training_session.aspx?CourseID=" & CourseID) ElseIf e.Item.Value = "Edit" Then RadScheduler1.AllowDelete = True RadScheduler1.AllowEdit = True RadScheduler1.AllowInsert = True ListViewPanelAttachment.Enabled = True RadAsyncUpload1.Enabled = True Tb_material_url.Enabled = True hl_material_url.Enabled = True rdl_select_location.Enabled = True rdl_select_trainer.Enabled = True rdl_select_employee.Enabled = True rdl_select_roletype.Enabled = True rdl_select_course.Enabled = True rdl_select_jobtitle.Enabled = True rdl_select_dept.Enabled = True RadListBox_select.Enabled = True RadListBox_unselect.Enabled = True btnSearch.Enabled = True RadScheduler1.Enabled = True rtbMenu.FindItemByValue("Edit").Enabled = False rtbMenu.FindItemByValue("Save").Enabled = True rtbMenu.FindItemByValue("Confirm").Enabled = False ElseIf e.Item.Value = "Save" Then UpdateValues() 'Dim dc As New dcLRDBDataContext 'Dim result = (From cs In dc.db_Training_Sessions Where cs.Session_ID = Request.QueryString("SessionID").ToString).FirstOrDefault 'If Not IsNothing(result) Then ' CourseID = result.Course_ID 'End If 'Response.Redirect("~/TrainingAdmin/training_session.aspx?CourseID=" & CourseID) RadScheduler1.AllowDelete = False RadScheduler1.AllowEdit = False RadScheduler1.AllowInsert = False Tb_material_url.Enabled = False hl_material_url.Enabled = False rdl_select_location.Enabled = False rdl_select_trainer.Enabled = False rdl_select_employee.Enabled = False rdl_select_course.Enabled = False rdl_select_jobtitle.Enabled = False rdl_select_dept.Enabled = False rdl_select_roletype.Enabled = False RadListBox_select.Enabled = False RadListBox_unselect.Enabled = False RadScheduler1.Enabled = False btnSearch.Enabled = False ListViewPanelAttachment.Enabled = False RadAsyncUpload1.Enabled = False rtbMenu.FindItemByValue("Edit").Enabled = True rtbMenu.FindItemByValue("Save").Enabled = False If HttpContext.Current.Session("SessionStatus") = "Confirmed" Then 'action if session had confirmed before rtbMenu.FindItemByValue("Confirm").Enabled = False ElseIf HttpContext.Current.Session("SessionStatus") = "Draft" Then rtbMenu.FindItemByValue("Confirm").Enabled = True End If ElseIf e.Item.Value = "Back" Then Response.Redirect("~/TrainingAdmin/training_session.aspx?CourseID=" & CourseID) ElseIf e.Item.Value = "Home" Then Response.Redirect("~/TrainingAdmin/training_course.aspx") End If End Sub Protected Sub rdl_select_course_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdl_select_course.SelectedIndexChanged If rdl_select_course.SelectedText <> rdl_select_course.DefaultMessage And rdl_select_course.SelectedText <> "" And rdl_select_location.Enabled = False Then 'rdl_select_location.ClearSelection() 'rdl_select_location.BorderWidth = "1" 'rdl_select_location.BorderColor = Drawing.Color.OrangeRed rdl_select_location.Enabled = True End If If rdl_select_course.SelectedText <> "" And rdl_select_location.SelectedText <> "" Then CheckValid("Course") End If End Sub Protected Sub rdl_select_location_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdl_select_location.SelectedIndexChanged If rdl_select_location.SelectedText <> rdl_select_location.DefaultMessage And rdl_select_trainer.Enabled = False Then 'rdl_select_location.BorderWidth = "0" 'rdl_select_trainer.BorderWidth = "1" rdl_select_trainer.Enabled = True 'rdl_select_trainer.BorderColor = Drawing.Color.OrangeRed End If CheckValid("Location") If Not IsNothing(Session("SelectedTrainerID")) Then rdl_select_trainer.SelectedValue = Session("SelectedTrainerID").ToString End If End Sub Protected Sub rdl_select_trainer_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rdl_select_trainer.SelectedIndexChanged If rdl_select_trainer.SelectedText <> rdl_select_trainer.DefaultMessage And rdl_select_employee.Enabled = False Then 'rdl_select_trainer.BorderWidth = "0" 'rdl_select_employee.BorderWidth = "1" rdl_select_employee.Enabled = True 'rdl_select_employee.BorderColor = Drawing.Color.OrangeRed End If End Sub Protected Sub CheckValid(ByVal ddl As String) Dim TID As String = "" If (ddl = "Location") Or (ddl = "Course") Then TID = GetAvailableTrainerIDByLocationIDCourseID(rdl_select_location.SelectedValue, rdl_select_course.SelectedValue) HttpContext.Current.Session("AvailableTrainerID") = TID If TID <> "" Then errmsg_ddl_trainer.Visible = False rdl_select_course.BorderWidth = "0" rdl_select_location.BorderWidth = "0" If (ddl = "Course") Then rdl_select_location.ClearSelection() rdl_select_location.SelectedText = rdl_select_trainer.DefaultMessage rdl_select_location.DataBind() End If rdl_select_trainer.ClearSelection() rdl_select_trainer.SelectedText = rdl_select_trainer.DefaultMessage rdl_select_trainer.DataBind() Else rdl_select_trainer.Enabled = False rdl_select_trainer.ClearSelection() 'rdl_select_employee.BorderWidth = "0" rdl_select_course.BorderWidth = "1" rdl_select_course.BorderColor = Drawing.Color.OrangeRed rdl_select_location.BorderWidth = "1" rdl_select_location.BorderColor = Drawing.Color.OrangeRed errmsg_ddl_trainer.Visible = True Tb_material_url.Enabled = False 'rdl_select_employee.ClearSelection() rdl_select_employee.Enabled = False RadScheduler1.Enabled = False End If End If End Sub Protected Sub RadScheduler1_AppointmentInsert(ByVal sender As Object, ByVal e As SchedulerCancelEventArgs) Dim scheduler As RadScheduler = TryCast(sender, RadScheduler) 'Dim room As Resource = e.Appointment.Resources.GetResourceByType("Room") 'Dim roomId As System.Nullable(Of Integer) = If(room IsNot Nothing, CType(room.Key, System.Nullable(Of Integer)), Nothing) Dim dc As New dcLRDBDataContext Dim SessionID As System.Nullable(Of Short) = 0 dc.insertSession(SessionID, Request.QueryString("SessionID").ToString, Session("SelectedPID").ToString, GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString, rdl_select_trainer.SelectedValue, rdl_select_location.SelectedValue, "Draft", e.Appointment.Start, e.Appointment.[End], e.Appointment.RecurrenceRule, CType(e.Appointment.RecurrenceParentID, System.Nullable(Of Integer)), DateTime.Now, HttpContext.Current.Session("UserID")) RadScheduler1.DataBind() End Sub Protected Sub RadScheduler1_AppointmentUpdate(ByVal sender As Object, ByVal e As AppointmentUpdateEventArgs) Dim scheduler As RadScheduler = TryCast(sender, RadScheduler) 'Dim room As Resource = e.ModifiedAppointment.Resources.GetResourceByType("Room") 'Dim roomId As System.Nullable(Of Integer) = If(room IsNot Nothing, CType(room.Key, System.Nullable(Of Integer)), Nothing) Dim dc As New dcLRDBDataContext dc.updateSession(Convert.ToInt32(e.Appointment.ID), Session("SelectedPID").ToString, GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString, rdl_select_trainer.SelectedValue, rdl_select_location.SelectedValue, "Draft", e.ModifiedAppointment.Start, e.ModifiedAppointment.[End], e.ModifiedAppointment.RecurrenceRule, _ CType(e.ModifiedAppointment.RecurrenceParentID, System.Nullable(Of Integer)), DateTime.Now, HttpContext.Current.Session("UserID")) RadScheduler1.DataBind() End Sub Protected Sub RadScheduler1_AppointmentDelete(ByVal sender As Object, ByVal e As SchedulerCancelEventArgs) Dim scheduler As RadScheduler = TryCast(sender, RadScheduler) Dim dc As New dcLRDBDataContext dc.deleteSession(Convert.ToInt32(e.Appointment.ID)) RadScheduler1.DataBind() End Sub Protected Sub DeleteRecords() Dim dc As New dcLRDBDataContext Dim result = (From cs In dc.db_Training_Sessions Where cs.Parent_ID = Request.QueryString("SessionID").ToString And (cs.status Is Nothing Or cs.status = "") Select cs.Session_ID).ToList Dim i As Integer If Not IsNothing(result) Then For i = 0 To result.Count - 1 dc.deleteSession(result.Item(i).ToString) Next End If dc.deleteSession(Request.QueryString("SessionID").ToString) End Sub Protected Sub UpdateValues() 'Remove value from db before insert (instead of update) Dim dc As New dcLRDBDataContext Dim result = (From cs In dc.db_Training_Session_Details Where cs.Session_ID = Request.QueryString("SessionID").ToString Select cs.Session_ID).ToList Dim i As Integer If Not IsNothing(result) Then For i = 0 To result.Count - 1 dc.deleteSessionDetails(result.Item(i).ToString) Next End If 'Insert list box selected value to db Dim dc2 As New dcLRDBDataContext For i = 0 To RadListBox_select.Items.Count - 1 dc2.insertSessionDetails_Employee(Request.QueryString("SessionID").ToString, RadListBox_select.Items(i).Value.ToString, DateTime.Now, HttpContext.Current.Session("UserID")) Next 'For i = 0 To RadListBoxDestination_Dept.Items.Count - 1 ' dc2.insertSessionDetails_Dept(Request.QueryString("SessionID").ToString, RadListBoxDestination_Dept.Items(i).Value.ToString, DateTime.Now, HttpContext.Current.Session("UserID")) 'Next 'For i = 0 To RadListBoxDestination_Employee.Items.Count - 1 ' dc2.insertSessionDetails_Employee(Request.QueryString("SessionID").ToString, RadListBoxDestination_Employee.Items(i).Value.ToString, DateTime.Now, HttpContext.Current.Session("UserID")) 'Next 'For i = 0 To RadListBoxDestination_RoleType.Items.Count - 1 ' dc2.insertSessionDetails_RoleType(Request.QueryString("SessionID").ToString, RadListBoxDestination_RoleType.Items(i).Value.ToString, DateTime.Now, HttpContext.Current.Session("UserID")) 'Next 'For i = 0 To RadListBoxDestination_Job_Title.Items.Count - 1 ' dc2.insertSessionDetails_JobTitle(Request.QueryString("SessionID").ToString, RadListBoxDestination_Job_Title.Items(i).Value.ToString, DateTime.Now, HttpContext.Current.Session("UserID")) 'Next Dim dc1 As New dcLRDBDataContext Dim start_time As System.Nullable(Of DateTime) = Nothing Dim end_time As System.Nullable(Of DateTime) = Nothing Dim rec1 = (From p In dc1.db_Training_Sessions Where p.Parent_ID = Request.QueryString("SessionID").ToString Order By p.Start_Time).FirstOrDefault If Not rec1 Is Nothing Then If Not IsNothing(rec1.Start_Time) Then start_time = rec1.Start_Time End If If Not IsNothing(rec1.End_Time) Then end_time = rec1.End_Time End If End If Dim dc3 As New dcLRDBDataContext Dim rec = (From p In dc3.db_Training_Sessions Where p.Session_ID = Request.QueryString("SessionID").ToString).FirstOrDefault If Not rec Is Nothing Then If rdl_select_location.SelectedText <> rdl_select_location.DefaultMessage And rdl_select_location.SelectedText <> "" Then rec.Location_ID = rdl_select_location.SelectedValue End If If rdl_select_trainer.SelectedText <> rdl_select_trainer.DefaultMessage And rdl_select_trainer.SelectedText <> "" Then rec.Trainer_ID = rdl_select_trainer.SelectedValue End If rec.LastUpdateDate = DateTime.Now rec.LastUpdateBy = HttpContext.Current.Session("UserID") If HttpContext.Current.Session("SessionStatus") = "Draft" Then rec.status = "Draft" ElseIf HttpContext.Current.Session("SessionStatus") = "Confirmed" Then rec.status = "Confirmed" End If If Tb_material_url.Text <> "" Then rec.MaterialURL = Tb_material_url.Text.Trim End If If Not IsNothing(start_time) Then rec.Date = start_time rec.Start_Time = start_time End If dc3.SubmitChanges() End If Using db As New dcLRDBDataContext Dim rec2 = From p In db.db_Training_Sessions Where p.Parent_ID = Request.QueryString("SessionID").ToString For Each p2 In rec2 If rdl_select_location.SelectedText <> rdl_select_location.DefaultMessage And rdl_select_location.SelectedText <> "" Then p2.Location_ID = rdl_select_location.SelectedValue End If If rdl_select_trainer.SelectedText <> rdl_select_trainer.DefaultMessage And rdl_select_trainer.SelectedText <> "" Then p2.Trainer_ID = rdl_select_trainer.SelectedValue End If p2.status = "Draft" p2.LastUpdateDate = DateTime.Now p2.LastUpdateBy = HttpContext.Current.Session("UserID") If Tb_material_url.Text <> "" Then p2.MaterialURL = Tb_material_url.Text.Trim End If If HttpContext.Current.Session("SessionStatus") = "Draft" Then p2.status = "Draft" ElseIf HttpContext.Current.Session("SessionStatus") = "Confirmed" Then p2.status = "Confirmed" End If Next db.SubmitChanges() End Using dc.Dispose() End Sub Protected Function CheckSessionExist() As Boolean Dim isExist As Boolean = False Dim dc1 As New dcLRDBDataContext Dim rec1 = (From p In dc1.db_Training_Sessions Where p.Parent_ID = Request.QueryString("SessionID").ToString Order By p.Start_Time).ToList If Not rec1 Is Nothing Then If rec1.Count > 0 Then isExist = True End If Else isExist = False End If Return isExist End Function Protected Function ConfirmTraining() As Boolean Dim confirm As Boolean = False Dim dc As New dcLRDBDataContext 'Insert into employee enrollments 'Retrieve employee_id from 3 listbox selected value Dim emp_list As String = "" Dim l As String = "" 'For i = 0 To RadListBoxDestination_Dept.Items.Count - 1 ' l += RadListBoxDestination_Dept.Items(i).Value.ToString & "," 'Next 'l = TrimList(l) 'emp_list += GetEmployeeIDByDeptID(l, HttpContext.Current.Session("SelectedPID").ToString) 'l = "" 'For i = 0 To RadListBoxDestination_RoleType.Items.Count - 1 ' l += RadListBoxDestination_RoleType.Items(i).Value.ToString & "," 'Next 'l = TrimList(l) 'If Len(emp_list) >= 1 Then ' emp_list += "," & GetEmployeeIDByRoleTypeID(l, HttpContext.Current.Session("SelectedPID").ToString) 'Else ' emp_list += GetEmployeeIDByRoleTypeID(l, HttpContext.Current.Session("SelectedPID").ToString) 'End If 'l = "" 'For i = 0 To RadListBoxDestination_Job_Title.Items.Count - 1 ' l += RadListBoxDestination_Job_Title.Items(i).Value.ToString & "," 'Next 'l = TrimList(l) 'If Len(emp_list) >= 1 Then ' emp_list += "," & GetEmployeeIDByJobTitleID(l, HttpContext.Current.Session("SelectedPID").ToString) 'Else ' emp_list += GetEmployeeIDByJobTitleID(l, HttpContext.Current.Session("SelectedPID").ToString) 'End If l = "" For i = 0 To RadListBox_select.Items.Count - 1 l += RadListBox_select.Items(i).Value.ToString & "," Next l = TrimList(l) If Len(emp_list) >= 1 Then emp_list += "," & l Else emp_list += l End If 'if more than or equal to 1 employee If Len(emp_list) > 1 Then 'distinct employee_id to array Dim elist = Split(emp_list, ",").ToArray.Distinct 'Dim dc1 As New dcLRDBDataContext 'Dim start_time As System.Nullable(Of DateTime) = Nothing 'Dim end_time As System.Nullable(Of DateTime) = Nothing 'Dim rec1 = (From p In dc1.db_Training_Sessions Where p.Parent_ID = Request.QueryString("SessionID").ToString Order By p.Start_Time).FirstOrDefault 'If Not rec1 Is Nothing Then ' If Not IsNothing(rec1.Start_Time) Then ' start_time = rec1.Start_Time ' End If ' If Not IsNothing(rec1.End_Time) Then ' end_time = rec1.End_Time ' End If 'End If 'For Each p In elist ' 'Dim p2 As Integer = Convert.ToInt32(p) ' dc.insertEmployeeEnrollment(Request.QueryString("SessionID").ToString, GetUserIDbyEmployeeID(p), GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString, "1", start_time, end_time, DateTime.Now, HttpContext.Current.Session("UserID")) 'Next Dim dc1 As New dcLRDBDataContext 'Dim start_time As System.Nullable(Of DateTime) = Nothing 'Dim end_time As System.Nullable(Of DateTime) = Nothing Dim start_time As DateTime Dim end_time As DateTime Dim traineroverlap As Boolean = False 'Check trainer available for all sessin first Dim sessionid3 As Integer Dim k As Integer Dim rec3 = (From p In dc1.db_Training_Sessions Where p.Parent_ID = Request.QueryString("SessionID").ToString Order By p.Start_Time).ToList If Not rec3 Is Nothing Then For k = 0 To rec3.Count - 1 start_time = rec3.Item(k).Start_Time end_time = rec3.Item(k).End_Time sessionid3 = rec3.Item(k).Session_ID If IsTrainerOverlapSession(rdl_select_trainer.SelectedValue.ToString, start_time, end_time) = True Then traineroverlap = True errMsg = "Trainer had overlap session with other training. Training cannot confirm." confirm = False End If Next End If 'if trainer available for all session If traineroverlap = False Then Dim sessionid As Integer Dim j As Integer 'Dim total_minutes As Integer Dim rec1 = (From p In dc1.db_Training_Sessions Where p.Parent_ID = Request.QueryString("SessionID").ToString Order By p.Start_Time).ToList If Not rec1 Is Nothing Then For j = 0 To rec1.Count - 1 start_time = rec1.Item(j).Start_Time end_time = rec1.Item(j).End_Time sessionid = rec1.Item(j).Session_ID Dim total_minutes = DateDiff(DateInterval.Minute, start_time, end_time) For Each p In elist 'Dim p2 As Integer = Convert.ToInt32(p) If p <> "" Then 'check exemption If CheckExemptionByUserIDCourseID(GetUserIDbyEmployeeID(p), GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString) = True Then confirm = False Else 'check study before If CheckEmployeeStudyBeforeByUserIDCourseID(GetUserIDbyEmployeeID(p), GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString) = True Then confirm = False Else 'Check overlap session If IsEmployeeOverlapSession(GetUserIDbyEmployeeID(p), start_time, end_time) = False Then dc.insertEmployeeEnrollment(sessionid, GetUserIDbyEmployeeID(p), GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString, "0", start_time, end_time, total_minutes, DateTime.Now, HttpContext.Current.Session("UserID")) confirm = True Else isOverlap = True 'alert/action if overlap End If End If End If End If Next If confirm = True Then 'Check Trainer overlap session If IsTrainerOverlapSession(rdl_select_trainer.SelectedValue.ToString, start_time, end_time) = False Then 'insert trainer schedule dc.insertTrainerSchedule(sessionid, GetUserIDbyTrainerID(rdl_select_trainer.SelectedValue).ToString, GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString, "1", start_time, end_time, DateTime.Now, HttpContext.Current.Session("UserID")) End If End If Next End If If confirm = False Then errMsg = "No employee selected for the training, training cannot confirm." End If If isOverlap = True Then errMsg = "All selected Employee had overlap session with other training. Training cannot confirm." End If If confirm = True Then 'insert training record For Each p In elist 'Dim p2 As Integer = Convert.ToInt32(p) If p <> "" Then 'check exemption If CheckExemptionByUserIDCourseID(GetUserIDbyEmployeeID(p), GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString) = True Then confirm = False Else 'check study before or not If CheckEmployeeStudyBeforeByUserIDCourseID(GetUserIDbyEmployeeID(p), GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString) = True Then confirm = False Else 'check overlap session If IsEmployeeOverlapSession(p, start_time, end_time) = False Then dc.insertTrainingRecord(Request.QueryString("SessionID").ToString, GetUserIDbyEmployeeID(p), p, GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString, "On Training", DateTime.Now, HttpContext.Current.Session("UserID")) confirm = True Else 'alert/action if overlap 'had taken action before (the loop function for insertEmployeeEnrollment) isOverlap = True overlapMsg += "- " & GetEmployeeDisplayNameByEmployeeID(p) & Environment.NewLine dc.insertTrainingSessionOverlapLog(sessionid, p, GetCourseIDBySessionID(Request.QueryString("SessionID")).ToString, start_time, end_time, DateTime.Now, HttpContext.Current.Session("UserID")) 'confirm = False 'errMsg = "Selected Employee had overlap session with other training. Training cannot confirm." 'errMsg = "No employee selected for the training, training cannot confirm." 'confirm = False End If End If End If End If Next 'Update status Dim rec = (From p In dc.db_Training_Sessions Where p.Session_ID = Request.QueryString("SessionID").ToString).FirstOrDefault If Not rec Is Nothing Then rec.status = "Confirmed" dc.SubmitChanges() End If 'Using db As New dcLRDBDataContext Dim rec2 = From p In dc.db_Training_Sessions Where p.Parent_ID = Request.QueryString("SessionID").ToString For Each p2 In rec2 p2.status = "Confirmed" Next dc.SubmitChanges() 'End Using dc.Dispose() 'action if overlap 'xxxxxxx confirm = True End If Else 'lb_msg.Visible = True 'lb_msg.Text = "No employee for the training, cannot confirm." 'Page.ClientScript.RegisterStartupScript(Page.GetType(), "MessageBox", "alert('No employee for the training, cannot confirm.');", True) confirm = False End If Else confirm = False End If Return confirm End Function Protected Sub btnSearch_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click Dim list_employee As String Dim list_roletype As String Dim list_dept As String Dim list_jobtitle As String Dim rList As String = "" Dim emp_list As String = "" If rdl_select_employee.SelectedText <> rdl_select_employee.DefaultMessage Then list_employee = rdl_select_employee.SelectedValue rList = GetEmployeeListByListByType(list_employee, "Employee") End If If rList <> String.Empty Then emp_list = rList & "," End If If rdl_select_roletype.SelectedText <> rdl_select_roletype.DefaultMessage Then list_roletype = rdl_select_roletype.SelectedValue rList = GetEmployeeListByListByType(list_roletype, "RoleType") End If If rList <> String.Empty Then emp_list += rList & "," End If If rdl_select_dept.SelectedText <> rdl_select_dept.DefaultMessage Then list_dept = rdl_select_dept.SelectedValue rList = GetEmployeeListByListByType(list_dept, "Dept") End If If rList <> String.Empty Then emp_list += rList & "," End If If rdl_select_jobtitle.SelectedText <> rdl_select_jobtitle.DefaultMessage Then list_jobtitle = rdl_select_jobtitle.SelectedValue rList = GetEmployeeListByListByType(list_jobtitle, "JobTitle") End If If rList <> String.Empty Then emp_list += rList End If emp_list = TrimList(emp_list) Dim eList = Split(emp_list, ",") Dim lista As New List(Of String)() lista.AddRange(eList.Distinct()) lista.Sort() 'already select before Dim list1 As String = "" Dim dc As New dcLRDBDataContext Dim i As Integer Dim rs = (From a In dc.db_Training_Session_Details _ Where a.Session_ID = Request.QueryString("SessionID") _ And a.Employee_ID IsNot Nothing _ Select a.Employee_ID).ToList If Not IsNothing(rs) Then If rs.Count > 0 Then For i = 0 To rs.Count - 1 list1 += rs.Item(i) & "," Next End If list1 = TrimList(list1) End If dc.Dispose() Dim eList2 = Split(list1, ",") Dim listb As New List(Of String)() listb.AddRange(eList2.Distinct()) listb.Sort() Dim c = lista.Except(listb).ToArray Array.Sort(c) Dim tmp As String = "" For Each x In c tmp += x & "," Next tmp = TrimList(tmp) HttpContext.Current.Session("EmpList") = tmp RadListBox_unselect.DataBind() End Sub Protected Sub RadScheduler1_DataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerEventArgs) If Not e.Appointment.ID Is Nothing Then 'Same Session If e.Appointment.ID = Request.QueryString("SessionID").ToString Then e.Appointment.BackColor = Drawing.Color.LightBlue Else 'Another course e.Appointment.BackColor = Drawing.Color.YellowGreen End If End If e.Appointment.AllowDelete = False e.Appointment.AllowEdit = False If e.Appointment.ID.ToString = Request.QueryString("SessionID").ToString Then e.Appointment.AllowDelete = True e.Appointment.AllowEdit = True End If End Sub Protected Sub CompleteTraining() Dim dc As New dcLRDBDataContext Dim i As Integer Dim rec = (From p In dc.db_Training_Sessions _ Where p.Session_ID = Request.QueryString("SessionID").ToString _ Or p.Parent_ID = Request.QueryString("SessionID").ToString _ Select p.Session_ID).ToList If Not rec Is Nothing Then For i = 0 To rec.Count - 1 dc.updateSessionStatus(rec.Item(i), "Completed", DateTime.Now, HttpContext.Current.Session("UserID")) Next dc.SubmitChanges() End If Dim rec2 = (From p In dc.db_Training_Records _ Where p.Session_ID = Request.QueryString("SessionID").ToString _ Select p.Training_Record_ID).ToList If Not rec2 Is Nothing Then For i = 0 To rec2.Count - 1 dc.updateTrainingRecordStatus(rec2.Item(i), "Completed", DateTime.Now, HttpContext.Current.Session("UserID")) Next dc.SubmitChanges() End If dc.Dispose() End Sub Protected Sub buttonSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) If RadAsyncUpload1.UploadedFiles.Count > 0 Then SaveFile(RadAsyncUpload1) ltrNoResults.Visible = False ' Repeater1.Visible = True Repeater1.DataSource = RadAsyncUpload1.UploadedFiles ' Repeater1.DataBind() RadListViewAttachment.DataBind() Else ltrNoResults.Visible = True ' Repeater1.Visible = False End If End Sub Protected Sub AsyncUpload_Attachment_FileUploaded(ByVal sender As Object, ByVal e As Telerik.Web.UI.FileUploadedEventArgs) End Sub Private _uploadedFiles As New List(Of Telerik.Web.UI.UploadedFileInfo)() Public Property UploadedFiles() As List(Of Telerik.Web.UI.UploadedFileInfo) Get Return _uploadedFiles End Get Set(ByVal value As List(Of Telerik.Web.UI.UploadedFileInfo)) _uploadedFiles = value End Set End Property Private Sub SaveFile(ByVal uf As RadAsyncUpload) Dim filePath As String = System.Configuration.ConfigurationManager.AppSettings("AttachmentPath").ToString() Dim fileName As String = "" Dim sessionid As Integer = Request.QueryString("SessionID") Dim dc As New dcLRDBDataContext For Each file As UploadedFile In uf.UploadedFiles Dim uploadedFileInfo As New UploadedFileInfo(file) UploadedFiles.Add(uploadedFileInfo) Dim newRecord1 As New db_Attachment dc.db_Attachments.InsertOnSubmit(newRecord1) newRecord1.FileName = sessionid & "_" & file.FileName newRecord1.FileSize = file.ContentLength / 1024 newRecord1.Description = file.GetFieldValue("Description") newRecord1.SessionID = sessionid newRecord1.UploadBy = HttpContext.Current.Session("UserID") newRecord1.UploadDate = DateTime.Now newRecord1.LastUpdatedOn = DateTime.Now newRecord1.LastUpdatedBy = HttpContext.Current.Session("UserID") dc.SubmitChanges() file.SaveAs(filePath & sessionid & "_" & file.FileName) Next dc.Dispose() End SubEnd Class
