<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmStuAbsenceApp.aspx.cs"
Inherits="M2_Absence_frmStuAbsenceApp" %>
<%@ Register Assembly="RadCalendar.Net2" Namespace="Telerik.WebControls" TagPrefix="radCln" %>
<%@ Register Assembly="RadTabStrip.Net2" Namespace="Telerik.WebControls" TagPrefix="radTS" %>
<%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript">
function GetRadWindow()
{
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz az well)
return oWindow;
}
function CancelEdit()
{
GetRadWindow().Close();
}
</script>
<head runat="server">
<title>New Application</title>
<link type="text/css" rel="stylesheet" href="../../Style/CSS/CssByLiu.css" />
<script type="text/javascript">
function CheckEmpty()
{
if (document.getElementById("tbTitle").value == "")
{
alert("Please input title!");
return false;
}
else
{
return true;
}
return false;
}
var rowI=0;
function addInput()
{
if(rowI >= 0)
{
rowI = parseInt(rowI)+1;
var objupload = document.getElementById("upload");
var obj = document.createElement("<input type=file name=myfile οnkeydοwn='return false' οnpaste='return false' oncut='return false' id=file"+rowI+" class='TextboxInput'>");
objupload.appendChild(obj);
//obj = document.createElement("<input type='hidden' value='"+document.getElementById("tbTitle").value+"' name='myhid"+rowI+"' id='myhid"+rowI+"'/>");
// objupload.appendChild(obj);
}
}
function tb_add()
{
var strFile = "file"+rowI;
//alert(strFile);
//eval("alert(document.all."+strFile+".value)");
if (document.getElementById("tbTitle").value == "" )
{
alert("Please input title!");
return false;
}
else if (document.getElementById(strFile).value == "")
{
alert("Please select file!");
return false;
}
else
{
var ls_t=document.all("dataGrid");
var rowCount = ls_t.rows.length;
var maxcell= ls_t.rows(0).cells.length;
var mynewrow = ls_t.insertRow(ls_t.rows.length);
for(i=0;i<maxcell;i++)
{
var mynewcell=mynewrow.insertCell();
if (i == 0)
{
mynewcell.innerText = document.getElementById("tbTitle").value;
mynewcell.align = "left";
}
if (i == 1)
{
mynewcell.innerText = "0";
mynewcell.align = "center";
mynewcell.width="50px"
}
if (i == 2)
{
mynewcell.innerHTML="<input type='button' class='button' width='70px' value='Remove' οnclick=tb_delete(event.srcElement.parentElement.parentElement) style='cursor:hand;'><input name=hidrow id=hidrow"+rowI+" value="+rowI+" style='width: 1px' type='hidden' /><input name=myhid id=myhid"+rowI+" value="+document.getElementById("tbTitle").value+" style='width: 1px' type='hidden' />";
mynewcell.align = "center";
mynewcell.width = "100px";
}
}
document.getElementById("tbTitle").value = "";
addInput();
document.getElementById(strFile).style.display = "none"
}
}
function tb_delete(row)
{
//var myrowIndex = row.rowIndex-1;
var e = row.cells(2).children[1];
var j = e.value;
var ls_t=document.all("dataGrid");
ls_t.deleteRow(row.rowIndex);
var objupload = document.getElementById("upload");
var fileid = "file"+(j);
//alert(fileid);
var objfile = document.getElementById(fileid);
//alert(objfile);
objupload.removeChild(objfile);
//var hidid = "myhid"+(j);
//var objhid = document.getElementById(hidid);
//objupload.removeChild(objhid);
}
</script>
</head>
<body class="DialogBody">
<form id="form1" runat="server" class="Form">
<table class="CommonTable">
<tr>
<td>
<radTS:RadTabStrip ID="tabStuAbsenceApp" runat="server" SelectedIndex="0" MultiPageID="multipageStuAbsenceApp"
Width="100%" Skin="Mac">
<Tabs>
<radTS:Tab runat="server" ID="tabGeneral" Text="General" PageViewID="pageGeneral">
</radTS:Tab>
<radTS:Tab runat="server" ID="tabAttachment" Text="Attachment" PageViewID="pageAttachment">
</radTS:Tab>
</Tabs>
</radTS:RadTabStrip>
</td>
</tr>
<tr>
<td>
<radTS:RadMultiPage ID="multipageStuAbsenceApp" runat="server" SelectedIndex="0"
Width="100%">
<radTS:PageView ID="pageGeneral" runat="server">
<table class="InTDTable">
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Student ID
</td>
<td class="TDCenter">
<asp:TextBox ID="tbStudentID" runat="server" CssClass="TextboxDisplay" ReadOnly="True"></asp:TextBox>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="height: 49px">
<table class="InTDTable">
<tr>
<td class="TDLeft">
Student Name
</td>
<td class="TDCenter">
<asp:TextBox ID="tbStudentName" runat="server" CssClass="TextboxDisplay" ReadOnly="True"></asp:TextBox>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Faculty
</td>
<td class="TDCenter">
<asp:TextBox ID="tbFaculty" runat="server" CssClass="TextboxDisplay" ReadOnly="True"></asp:TextBox>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Course
</td>
<td class="TDCenter">
<asp:TextBox ID="tbCourse" runat="server" CssClass="TextboxDisplay" ReadOnly="True"></asp:TextBox>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Academic Year
</td>
<td class="TDCenter">
<asp:TextBox ID="tbAcademicYear" runat="server" CssClass="TextboxDisplay" ReadOnly="True"></asp:TextBox>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Semester
</td>
<td class="TDCenter">
<asp:TextBox ID="tbSemester" runat="server" CssClass="TextboxDisplay" ReadOnly="True"></asp:TextBox>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Region Center
</td>
<td class="TDCenter">
<asp:TextBox ID="tbRegionCenter" runat="server" CssClass="TextboxDisplay" ReadOnly="True"></asp:TextBox>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Learning Center
</td>
<td class="TDCenter">
<asp:TextBox ID="tbLearningCenter" runat="server" CssClass="TextboxDisplay" ReadOnly="True"></asp:TextBox>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Leave of Absence
</td>
<td class="TDCenter">
<radCln:RadDateTimePicker ID="rdtFrom" runat="server" Culture="English (United States)">
<DateInput CssClass="DateTimePickerInput" Skin="" BorderColor="Orange">
</DateInput>
<TimeView Skin="" Style="display: none;">
</TimeView>
</radCln:RadDateTimePicker>
To
<radCln:RadDateTimePicker ID="rdtTo" runat="server" Culture="English (United States)">
<DateInput CssClass="DateTimePickerInput" Skin="" BorderColor="Orange">
</DateInput>
<TimeView Skin="" Style="display: none;">
</TimeView>
</radCln:RadDateTimePicker>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="rdtFrom"
Display="Dynamic" ErrorMessage="Please input Absence From "></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="rdtTo"
Display="Dynamic" ErrorMessage="Please input Absenct To"></asp:RequiredFieldValidator></td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Reason
</td>
<td class="TDCenter">
<textarea id="taReason" rows="8" class="TextboxInput" style="width: 99%" runat="server"></textarea>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="taReason"
Display="Dynamic" ErrorMessage="Please input Reason!"></asp:RequiredFieldValidator></td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft" style="height: 20px">
</td>
<td class="TDCenter" align="center" style="height: 20px">
</td>
<td class="TDRight" style="height: 20px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</radTS:PageView>
<radTS:PageView ID="pageAttachment" runat="server">
<table class="InTDTable">
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Title</td>
<td class="TDCenter">
<asp:TextBox ID="tbTitle" runat="server" CssClass="TextboxInput"></asp:TextBox>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
File
</td>
<td class="TDCenter">
<table id="filetable" border="0" cellpadding="0" width="100%" cellspacing="0">
<tr id="tr0">
<td>
<span id="upload">
<input type="file" οnkeydοwn="return false" οnpaste="return false" oncut="return false" id="file0" runat="server" class="TextboxInput" />
<input id="hid0" style="width: 1px" type="hidden" />
</span>
</td>
</tr>
</table>
</td>
<td class="TDRight">
إدارة الشؤون الأكاديمية والإدارية
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
Attachment List
</td>
<td class="TDCenter">
<table id="dataGrid" width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<b>Title</b></td>
<td align="center" width="50px">
<b>Size</b></td>
<td align="center" width="100px">
<b> </b></td>
</tr>
</table>
</td>
<td class="TDRight">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
</td>
<td class="TDCenter">
<table class="InTDTable">
<tr>
<td class="TDButton">
<input id="btnAdd" οnclick="tb_add()" class="button" type="button" value="Add" /></td>
<td>
</td>
</tr>
</table>
</td>
<td class="TDRight">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
</td>
<td class="TDCenter">
</td>
<td class="TDRight">
</td>
</tr>
</table>
</td>
</tr>
</table>
</radTS:PageView>
</radTS:RadMultiPage>
</td>
</tr>
<tr>
<td>
<table class="InTDTable">
<tr>
<td class="TDLeft">
</td>
<td class="TDCenter">
<table class="InTDTable">
<tr>
<td class="TDButton" style="width: 5%; height: 22px">
</td>
<td class="TDButton" style="width: 5%; height: 22px">
<input type="button" id="btnSubmit" value="Submit" class="button" onserverclick="btnSubmit_ServerClick"
runat="server" /></td>
<td style="height: 22px">
<input type="button" id="btnClose" value="Close" οnclick="CancelEdit()" class="button" /></td>
</tr>
</table>
</td>
<td class="TDRight">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
protected void btnSubmit_ServerClick(object sender, EventArgs e)
{
TBAbsenceAttachmentDetails attach = null;
for (int i = 0; i < Request.Files.Count-1; i++)
{
attach = new TBAbsenceAttachmentDetails();
HttpPostedFile postfile = Request.Files[i];
string fn = System.IO.Path.GetFileName(postfile.FileName);
attach.GUID = Guid.NewGuid();
attach.FileSize = Convert.ToString(Math.Round(Convert.ToDouble(Convert.ToDouble(postfile.ContentLength) / 1024), 2));
string ss = Request.Form["myhid"];
string[] strTitle = Request.Form["myhid"].Split(',');
//
attach.Title = strTitle[i];
//
attach.FileName = fn;
byte[] filebyte = new byte[postfile.ContentLength];
System.IO.Stream StreamObject = postfile.InputStream;
StreamObject.Read(filebyte, 0, postfile.ContentLength);
attach.Content = filebyte;
attach.AddUser = GetUserEntity().UserName;
attach.EditUser = GetUserEntity().UserName;
attachlist.Add(attach);
}
BLL_TBAbsenceApp absenceapp = new BLL_TBAbsenceApp();
TBAbsenceAppDetails absencedetail = new TBAbsenceAppDetails();
absencedetail.GUID = Guid.NewGuid();
absencedetail.StudentID = GetUserEntity().StudentID;
absencedetail.AbsenceFrom = Convert.ToDateTime(this.rdtFrom.SelectedDate);
absencedetail.AbsenceTo = Convert.ToDateTime(this.rdtTo.SelectedDate);
absencedetail.Reason = this.taReason.Value;
absencedetail.AppStatus = Convert.ToInt32(AbsenceApp.New).ToString();
int ret = absenceapp.Insert(absencedetail, attachlist);
if (ret > 0)
{
ClientScript.RegisterStartupScript(this.GetType(), "re", "<script> var oWindow = null;if (window.radWindow) oWindow = window.radWindow;else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;alert('Submit successed!'); oWindow.Close();window.parent.Main.location.href=window.parent.Main.location.href;</script>");
}
}