19-03-2020----------Developer/DeveloperLeave.aspx
Developer/DeveloperLeave.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/Developer/DeveloperMaster.master" AutoEventWireup="true" CodeFile="DeveloperLeave.aspx.cs" Inherits="Developer_DeveloperLeave" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div style="text-align: center;" id="blink"><%=WorkDoneorNot%></div>
<%--You have not started any work till now. You are sitting ideal since last 1 hours.--%>
<script type="text/javascript">
var blink = document.getElementById('blink');
setInterval(function () {
blink.style.opacity = (blink.style.opacity == 0 ? 1 : 0);
}, 1000);
</script>
<table width="70%" border="1" align="center" cellpadding="3" cellspacing="1" class="tdrow4">
<tr>
<td width="882" align="center" bgcolor="#E6E6E6">
<table width="100%" height="15" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="Tab3" align="left"><a href="attendance.aspx"><font color="#0000FF"><b>Attendance</b></font></a></td>
<td class="Tab3" align="left"><a href="OutsideInside.aspx"><font color="#0000FF"><b>Outside Inside</b></font></a></td>
<td class="Tab3" align="left"><a href="add_reminder.aspx" target="_blank"><font color="#0000FF"><b>Add New Reminder</b></font></a></td>
<td class="Tab3" align="left">
<%if (leaveApplyFormStatus > 0)
{%>
<a href="DeveloperLeave.aspx" target="_blank" class="notification"><font color="#0000FF"><b>Leave Apply Form</b></font>
<span class="badge">
<%=leaveApplyFormStatus%></span>
</a>
<%} %>
<%else
{ %>
<a href="DeveloperLeave.aspx" target="_blank"><font color="#0000FF"><b>Leave Apply Form</b></font></a>
<%} %>
</td>
<td class="Tab3" align="left">
<%if (numberOfSeenStatus > 0)
{%>
<a href="DeveloperLeaveStatus.aspx" target="_blank" class="notification"><font color="#0000FF"><b>Applied Leave Status</b></font><span class="badge">
<%=numberOfSeenStatus%></span></a>
<%} %>
<%else
{ %>
<a href="DeveloperLeaveStatus.aspx" target="_blank"><font color="#0000FF"><b>Applied Leave Status</b></font></a>
<%} %>
</td>
<td class="Tab3" align="left">
<%if (numberOfPendingApprovalLeave > 0)
{%>
<a href="developerGrantLeave.aspx" target="_blank" class="notification"><font color="#0000FF"><b>Leave Grant</b></font><span class="badge">
<%=numberOfPendingApprovalLeave%></span></a>
<%} %>
<%else
{ %>
<a href="developerGrantLeave.aspx" target="_blank" ><font color="#0000FF"><b>Leave Grant</b></font></a>
<%} %>
</td>
<td class="Tab3" align="right"><a href="view_reminder.aspx" target="_blank"><font color="#0000FF"><b>View Done Reminder</b></font></a></td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
<%=ReminderPanel%>
</table>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script>
$(document).ready(function () {
// Date Object
//var date = new Date();
//date.setDate(date.getDate() + 7);
var date =null;
if ('<%=dtCurrentFormDate%>' != '') {
date = new Date('<%=dtCurrentFormDate%>');
$('.ddlApprovedByClass').prop('disabled', true);
document.getElementById("<%=RequiredFieldValidator8.ClientID %>").enabled = false;
}
else
{
date = new Date();
date.setDate(date.getDate() + 7);
$('.ddlApprovedByClass').prop('disabled', false);
document.getElementById("<%=RequiredFieldValidator8.ClientID %>").enabled = true;
}
$('.dateFrom').datepicker({
dateFormat: "yy-mm-dd",
minDate: date,
onSelect: function (selected) {
var dt = new Date(selected);
dt.setDate(dt.getDate() + 1);
$(".dateTo").datepicker("option", "minDate", dt);
},
});
$(".dateTo").datepicker({
dateFormat: "yy-mm-dd",
minDate: date,
onSelect: function (selected) {
var dt = new Date(selected);
dt.setDate(dt.getDate() - 1);
$(".dateFrom").datepicker("option", "maxDate", dt);
}
});
});
</script>
<h5>Leave Application Form (Please fill this form atleast 7 days before.)</h5>
<asp:Label ID="lblmsg" runat="server" style="color:green;"></asp:Label>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>Date From: </td><td style="width:23px;"><asp:TextBox ID="txtFrom" runat="server" type="text" class="dateFrom" placeholder="yyyyy-mm-dd" autocomplete="off"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtFrom"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td><td>Date To: </td><td colspan="3"><asp:TextBox ID="txtTo" runat="server" class="dateTo" placeholder="yyyyy-mm-dd" autocomplete="off"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtTo"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Last Working day: </td><td ><asp:TextBox ID="txtLastWorkingDay" runat="server" placeholder="Last working day & Date before leave" style="margin: 0px; width: 500px; height: 60px;" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtLastWorkingDay"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td><td >Reporting Date: </td><td colspan="3"><asp:TextBox ID="txtReportingDate" runat="server" placeholder="Reporting Date & Day" style="height: 25px;width: 162px;"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtReportingDate"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Address: </td><td ><asp:TextBox ID="txtAddress" runat="server" placeholder="Address during leave period" style="margin: 0px; width: 500px; height: 60px;" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtAddress"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td><td >Mobile No: </td><td colspan="3"><asp:TextBox ID="txtMobileNo" runat="server" placeholder="Mobile Number" style="height: 25px;width: 162px;"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtMobileNo"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Jobs TO Do Before Leave :</td><td colspan="5"> <asp:TextBox ID="txtJobsTODoBeforeLeave" runat="server" style="margin: 0px; width: 1153px; height: 73px;"
TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtJobsTODoBeforeLeave"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Reason for Leave:</td><td colspan="5"> <asp:TextBox ID="txtReasonforLeave" runat="server" placeholder="Reason for Leave" style="margin: 0px; width: 1153px; height: 105px;" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtReasonforLeave"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<%--<td>Job Profile:</td><td> <input type="text" /></td>--%>
<td>Approved By: </td><td colspan="5">
<%--<select style="width:172px;height:31px;"><option>--Select--</option><option>Ram</option><option>Radha</option></select>--%>
<asp:DropDownList ID="ddlApprovedBy" class="ddlApprovedByClass" runat="server" Width="150" style="width:172px;height:31px;">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" class="ddlApprovedByValidClass" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="ddlApprovedBy"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr align="center">
<td colspan="6">
<%--<input type="button" value="Submit" />--%>
<asp:Button ID="btnsubmit" runat="server" Text="Submit" ToolTip="Submit" ValidationGroup="valgroup"
Style="cursor: pointer; width: 150px;" OnClick="btnSubmit_Click" CssClass="Tab2" />
</td>
</tr>
</table>
</asp:Content>
Developer/DeveloperLeave.aspx.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Developer_DeveloperLeave : System.Web.UI.Page
{
MainClass dut = new MainClass();
DataAccessLayer dal = new DataAccessLayer();
public string dv_name, PendingTask, ReminderPanel,WorkDoneorNot = string.Empty;
public int numberOfPendingApprovalLeave = 0;
public int numberOfSeenStatus = 0, leaveApplyFormStatus=0;
//public string dtCurrentFormDate = DateTime.Today.ToString("yyyy-MM-dd");
public string dtCurrentFormDate = "";
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["developer_srno"] != null)
{
var value = Request.Cookies["developer_srno"].Value;
if (value == "")
{
Response.Redirect("~/Pr-Admin-Log");
}
Session["developer_srno"] = value;
}
else
{
Response.Redirect("~/Pr-Admin-Log");
}
if (!IsPostBack)
{
if (Convert.ToString(Session["msgg"]) != "")
{
lblmsg.Text = Convert.ToString(Session["msgg"]);
Session["msgg"] = null;
}
bindApprovedBy();
checkSeenStatus();
checkLeaveGrant();
checkAnyWorkDoneorNot();
}
checkApplyFormStatus();
}
private void checkAnyWorkDoneorNot()
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@srno" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]) };
DataSet ds4 = dal.getDataSet("USPcheckAnyWorkDoneorNot", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
WorkDoneorNot = Convert.ToString(ds4.Tables[0].Rows[0]["msg"]);
}
}
}
catch (Exception ex)
{
}
}
private void checkApplyFormStatus()
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@srno", "@Actiontype" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]), "checkinstanceleave" };
DataSet ds4 = dal.getDataSet("ManageLeave", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
leaveApplyFormStatus = ds4.Tables[0].Rows.Count;
dtCurrentFormDate = Convert.ToDateTime(ds4.Tables[0].Rows[0]["dateFrom"]).ToString("yyyy-MM-dd"); ;
}
else
{
leaveApplyFormStatus = 0;
dtCurrentFormDate = "";
}
}
}
catch (Exception ex)
{
}
}
public void bindApprovedBy()
{
string[] col4 = { "@srno", "@Actiontype" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]), "approvedby" };
DataSet ds4 = dal.getDataSet("ManageLeave", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
ddlApprovedBy.DataSource = ds4.Tables[0];
ddlApprovedBy.DataTextField = "name";
ddlApprovedBy.DataValueField = "srno";
ddlApprovedBy.DataBind();
ddlApprovedBy.Items.Insert(0, new ListItem("--Select--", ""));
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@dateFrom", "@dateTo", "@srno", "@lastworkingday", "@reportingday", "@address", "@mobilenumber", "@JobsTODoBeforeLeave", "@ReasonforLeave", "@approvedBy", "@Actiontype" };
object[] val4 = {new DateTime(Convert.ToInt32(txtFrom.Text.Split('-')[0]),Convert.ToInt32(txtFrom.Text.Split('-')[1]),Convert.ToInt32(txtFrom.Text.Split('-')[2])),new DateTime(Convert.ToInt32(txtTo.Text.Split('-')[0]),Convert.ToInt32(txtTo.Text.Split('-')[1]),Convert.ToInt32(txtTo.Text.Split('-')[2])),Convert.ToInt32(Session["developer_srno"]),txtLastWorkingDay.Text,txtReportingDate.Text,txtAddress.Text,
txtMobileNo.Text,txtJobsTODoBeforeLeave.Text,txtReasonforLeave.Text,ddlApprovedBy.SelectedValue,((ddlApprovedBy.SelectedValue==""&&leaveApplyFormStatus==1)?"instantleaveapply": "insert") };
int i = dal.execute("ManageLeave", col4, val4);
if (i == 1)
{
Session["msgg"] = "Data Inserted Successfuly.";
Response.Redirect("~/Developer/DeveloperLeave.aspx");
}
else
{
Session["msgg"] = "Error in Submition.";
}
}
else
{
Response.Redirect("~/Pr-Admin-Log");
}
}
catch (Exception ex)
{
}
}
private void checkSeenStatus()
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@srno", "@Actiontype" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]), "checkseenstatusbyemployee" };
DataSet ds4 = dal.getDataSet("ManageLeave", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
numberOfSeenStatus = ds4.Tables[0].Rows.Count;
}
}
}
catch (Exception ex)
{
}
}
private void checkLeaveGrant()
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@srno", "@Actiontype" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]), "showpendingleavestatus" };
DataSet ds4 = dal.getDataSet("ManageLeave", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
numberOfPendingApprovalLeave = ds4.Tables[0].Rows.Count;
}
}
}
catch (Exception ex)
{
}
}
}
<%@ Page Title="" Language="C#" MasterPageFile="~/Developer/DeveloperMaster.master" AutoEventWireup="true" CodeFile="DeveloperLeave.aspx.cs" Inherits="Developer_DeveloperLeave" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div style="text-align: center;" id="blink"><%=WorkDoneorNot%></div>
<%--You have not started any work till now. You are sitting ideal since last 1 hours.--%>
<script type="text/javascript">
var blink = document.getElementById('blink');
setInterval(function () {
blink.style.opacity = (blink.style.opacity == 0 ? 1 : 0);
}, 1000);
</script>
<table width="70%" border="1" align="center" cellpadding="3" cellspacing="1" class="tdrow4">
<tr>
<td width="882" align="center" bgcolor="#E6E6E6">
<table width="100%" height="15" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="Tab3" align="left"><a href="attendance.aspx"><font color="#0000FF"><b>Attendance</b></font></a></td>
<td class="Tab3" align="left"><a href="OutsideInside.aspx"><font color="#0000FF"><b>Outside Inside</b></font></a></td>
<td class="Tab3" align="left"><a href="add_reminder.aspx" target="_blank"><font color="#0000FF"><b>Add New Reminder</b></font></a></td>
<td class="Tab3" align="left">
<%if (leaveApplyFormStatus > 0)
{%>
<a href="DeveloperLeave.aspx" target="_blank" class="notification"><font color="#0000FF"><b>Leave Apply Form</b></font>
<span class="badge">
<%=leaveApplyFormStatus%></span>
</a>
<%} %>
<%else
{ %>
<a href="DeveloperLeave.aspx" target="_blank"><font color="#0000FF"><b>Leave Apply Form</b></font></a>
<%} %>
</td>
<td class="Tab3" align="left">
<%if (numberOfSeenStatus > 0)
{%>
<a href="DeveloperLeaveStatus.aspx" target="_blank" class="notification"><font color="#0000FF"><b>Applied Leave Status</b></font><span class="badge">
<%=numberOfSeenStatus%></span></a>
<%} %>
<%else
{ %>
<a href="DeveloperLeaveStatus.aspx" target="_blank"><font color="#0000FF"><b>Applied Leave Status</b></font></a>
<%} %>
</td>
<td class="Tab3" align="left">
<%if (numberOfPendingApprovalLeave > 0)
{%>
<a href="developerGrantLeave.aspx" target="_blank" class="notification"><font color="#0000FF"><b>Leave Grant</b></font><span class="badge">
<%=numberOfPendingApprovalLeave%></span></a>
<%} %>
<%else
{ %>
<a href="developerGrantLeave.aspx" target="_blank" ><font color="#0000FF"><b>Leave Grant</b></font></a>
<%} %>
</td>
<td class="Tab3" align="right"><a href="view_reminder.aspx" target="_blank"><font color="#0000FF"><b>View Done Reminder</b></font></a></td>
</tr>
<tr>
<td>
<asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label>
</td>
</tr>
</table>
</td>
</tr>
<%=ReminderPanel%>
</table>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script>
$(document).ready(function () {
// Date Object
//var date = new Date();
//date.setDate(date.getDate() + 7);
var date =null;
if ('<%=dtCurrentFormDate%>' != '') {
date = new Date('<%=dtCurrentFormDate%>');
$('.ddlApprovedByClass').prop('disabled', true);
document.getElementById("<%=RequiredFieldValidator8.ClientID %>").enabled = false;
}
else
{
date = new Date();
date.setDate(date.getDate() + 7);
$('.ddlApprovedByClass').prop('disabled', false);
document.getElementById("<%=RequiredFieldValidator8.ClientID %>").enabled = true;
}
$('.dateFrom').datepicker({
dateFormat: "yy-mm-dd",
minDate: date,
onSelect: function (selected) {
var dt = new Date(selected);
dt.setDate(dt.getDate() + 1);
$(".dateTo").datepicker("option", "minDate", dt);
},
});
$(".dateTo").datepicker({
dateFormat: "yy-mm-dd",
minDate: date,
onSelect: function (selected) {
var dt = new Date(selected);
dt.setDate(dt.getDate() - 1);
$(".dateFrom").datepicker("option", "maxDate", dt);
}
});
});
</script>
<h5>Leave Application Form (Please fill this form atleast 7 days before.)</h5>
<asp:Label ID="lblmsg" runat="server" style="color:green;"></asp:Label>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>Date From: </td><td style="width:23px;"><asp:TextBox ID="txtFrom" runat="server" type="text" class="dateFrom" placeholder="yyyyy-mm-dd" autocomplete="off"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtFrom"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td><td>Date To: </td><td colspan="3"><asp:TextBox ID="txtTo" runat="server" class="dateTo" placeholder="yyyyy-mm-dd" autocomplete="off"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtTo"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Last Working day: </td><td ><asp:TextBox ID="txtLastWorkingDay" runat="server" placeholder="Last working day & Date before leave" style="margin: 0px; width: 500px; height: 60px;" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtLastWorkingDay"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td><td >Reporting Date: </td><td colspan="3"><asp:TextBox ID="txtReportingDate" runat="server" placeholder="Reporting Date & Day" style="height: 25px;width: 162px;"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtReportingDate"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Address: </td><td ><asp:TextBox ID="txtAddress" runat="server" placeholder="Address during leave period" style="margin: 0px; width: 500px; height: 60px;" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtAddress"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td><td >Mobile No: </td><td colspan="3"><asp:TextBox ID="txtMobileNo" runat="server" placeholder="Mobile Number" style="height: 25px;width: 162px;"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtMobileNo"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Jobs TO Do Before Leave :</td><td colspan="5"> <asp:TextBox ID="txtJobsTODoBeforeLeave" runat="server" style="margin: 0px; width: 1153px; height: 73px;"
TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtJobsTODoBeforeLeave"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>Reason for Leave:</td><td colspan="5"> <asp:TextBox ID="txtReasonforLeave" runat="server" placeholder="Reason for Leave" style="margin: 0px; width: 1153px; height: 105px;" TextMode="MultiLine"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="txtReasonforLeave"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<%--<td>Job Profile:</td><td> <input type="text" /></td>--%>
<td>Approved By: </td><td colspan="5">
<%--<select style="width:172px;height:31px;"><option>--Select--</option><option>Ram</option><option>Radha</option></select>--%>
<asp:DropDownList ID="ddlApprovedBy" class="ddlApprovedByClass" runat="server" Width="150" style="width:172px;height:31px;">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator8" class="ddlApprovedByValidClass" runat="server" ErrorMessage="*"
InitialValue="" ValidationGroup="valgroup" Display="Dynamic" ControlToValidate="ddlApprovedBy"
SetFocusOnError="true" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr align="center">
<td colspan="6">
<%--<input type="button" value="Submit" />--%>
<asp:Button ID="btnsubmit" runat="server" Text="Submit" ToolTip="Submit" ValidationGroup="valgroup"
Style="cursor: pointer; width: 150px;" OnClick="btnSubmit_Click" CssClass="Tab2" />
</td>
</tr>
</table>
</asp:Content>
Developer/DeveloperLeave.aspx.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Developer_DeveloperLeave : System.Web.UI.Page
{
MainClass dut = new MainClass();
DataAccessLayer dal = new DataAccessLayer();
public string dv_name, PendingTask, ReminderPanel,WorkDoneorNot = string.Empty;
public int numberOfPendingApprovalLeave = 0;
public int numberOfSeenStatus = 0, leaveApplyFormStatus=0;
//public string dtCurrentFormDate = DateTime.Today.ToString("yyyy-MM-dd");
public string dtCurrentFormDate = "";
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Cookies["developer_srno"] != null)
{
var value = Request.Cookies["developer_srno"].Value;
if (value == "")
{
Response.Redirect("~/Pr-Admin-Log");
}
Session["developer_srno"] = value;
}
else
{
Response.Redirect("~/Pr-Admin-Log");
}
if (!IsPostBack)
{
if (Convert.ToString(Session["msgg"]) != "")
{
lblmsg.Text = Convert.ToString(Session["msgg"]);
Session["msgg"] = null;
}
bindApprovedBy();
checkSeenStatus();
checkLeaveGrant();
checkAnyWorkDoneorNot();
}
checkApplyFormStatus();
}
private void checkAnyWorkDoneorNot()
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@srno" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]) };
DataSet ds4 = dal.getDataSet("USPcheckAnyWorkDoneorNot", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
WorkDoneorNot = Convert.ToString(ds4.Tables[0].Rows[0]["msg"]);
}
}
}
catch (Exception ex)
{
}
}
private void checkApplyFormStatus()
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@srno", "@Actiontype" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]), "checkinstanceleave" };
DataSet ds4 = dal.getDataSet("ManageLeave", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
leaveApplyFormStatus = ds4.Tables[0].Rows.Count;
dtCurrentFormDate = Convert.ToDateTime(ds4.Tables[0].Rows[0]["dateFrom"]).ToString("yyyy-MM-dd"); ;
}
else
{
leaveApplyFormStatus = 0;
dtCurrentFormDate = "";
}
}
}
catch (Exception ex)
{
}
}
public void bindApprovedBy()
{
string[] col4 = { "@srno", "@Actiontype" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]), "approvedby" };
DataSet ds4 = dal.getDataSet("ManageLeave", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
ddlApprovedBy.DataSource = ds4.Tables[0];
ddlApprovedBy.DataTextField = "name";
ddlApprovedBy.DataValueField = "srno";
ddlApprovedBy.DataBind();
ddlApprovedBy.Items.Insert(0, new ListItem("--Select--", ""));
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@dateFrom", "@dateTo", "@srno", "@lastworkingday", "@reportingday", "@address", "@mobilenumber", "@JobsTODoBeforeLeave", "@ReasonforLeave", "@approvedBy", "@Actiontype" };
object[] val4 = {new DateTime(Convert.ToInt32(txtFrom.Text.Split('-')[0]),Convert.ToInt32(txtFrom.Text.Split('-')[1]),Convert.ToInt32(txtFrom.Text.Split('-')[2])),new DateTime(Convert.ToInt32(txtTo.Text.Split('-')[0]),Convert.ToInt32(txtTo.Text.Split('-')[1]),Convert.ToInt32(txtTo.Text.Split('-')[2])),Convert.ToInt32(Session["developer_srno"]),txtLastWorkingDay.Text,txtReportingDate.Text,txtAddress.Text,
txtMobileNo.Text,txtJobsTODoBeforeLeave.Text,txtReasonforLeave.Text,ddlApprovedBy.SelectedValue,((ddlApprovedBy.SelectedValue==""&&leaveApplyFormStatus==1)?"instantleaveapply": "insert") };
int i = dal.execute("ManageLeave", col4, val4);
if (i == 1)
{
Session["msgg"] = "Data Inserted Successfuly.";
Response.Redirect("~/Developer/DeveloperLeave.aspx");
}
else
{
Session["msgg"] = "Error in Submition.";
}
}
else
{
Response.Redirect("~/Pr-Admin-Log");
}
}
catch (Exception ex)
{
}
}
private void checkSeenStatus()
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@srno", "@Actiontype" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]), "checkseenstatusbyemployee" };
DataSet ds4 = dal.getDataSet("ManageLeave", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
numberOfSeenStatus = ds4.Tables[0].Rows.Count;
}
}
}
catch (Exception ex)
{
}
}
private void checkLeaveGrant()
{
try
{
if (Session["developer_srno"] != null)
{
string[] col4 = { "@srno", "@Actiontype" };
object[] val4 = { Convert.ToInt32(Session["developer_srno"]), "showpendingleavestatus" };
DataSet ds4 = dal.getDataSet("ManageLeave", col4, val4);
if (ds4.Tables[0].Rows.Count > 0)
{
numberOfPendingApprovalLeave = ds4.Tables[0].Rows.Count;
}
}
}
catch (Exception ex)
{
}
}
}
Comments
Post a Comment