首页 > 其他 > 详细

节假日设置

时间:2015-05-11 12:43:49      阅读:278      评论:0      收藏:0      [点我收藏+]

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/WorkTemplate.Master"
AutoEventWireup="true" CodeBehind="Ndpx_add.aspx.cs" Inherits="Fencer_OA.Zhxz.add.Ndpx_add" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<%-- <link href="../../Css/BasicLayout.css" type="text/css" rel="stylesheet" />--%>
<script type="text/javascript" src="../../js/meizzDate.js"></script>
<script type="text/javascript" src="../../My97DatePicker/WdatePicker.js"></script>
<script language="jscript" type="text/javascript">
function fillstring(str) {
if (str.length == 1) {
str = "0" + str;
}
return (str);
}
function quickseldate(type) {
var begintime, endtime;
var oneminute = 60 * 1000;
var onehour = 60 * oneminute;
var oneday = 24 * onehour;
var oneweek = 7 * oneday;
var todayDate = new Date();
var date = todayDate.getDate();
var month = todayDate.getMonth() + 1;
var year = todayDate.getYear();
var day = todayDate.getDay();
if (navigator.appName == "Netscape") {
year = 1900 + year;
}
if (type == "day") {
begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
endtime = begintime;
}
else if (type == "week") {
var daytoMon = day - 1;
if (day == 0)
daytoMon = 6;

todayDate.setTime(todayDate.getTime() - daytoMon * oneday);
date = todayDate.getDate();
month = todayDate.getMonth() + 1;
year = todayDate.getYear();
day = todayDate.getDay();

begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());

todayDate.setTime(todayDate.getTime() + 6 * oneday);

date = todayDate.getDate();
month = todayDate.getMonth() + 1;
year = todayDate.getYear();

endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
}
else if (type == "month") {
var dateto1 = date - 1;

todayDate.setTime(todayDate.getTime() - dateto1 * oneday);
date = todayDate.getDate();
month = todayDate.getMonth() + 1;
year = todayDate.getYear();
day = todayDate.getDay();

begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());

todayDate.setMonth(month);
todayDate.setTime(todayDate.getTime() - oneday);

date = todayDate.getDate();
month = todayDate.getMonth() + 1;
year = todayDate.getYear();
endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
}
$("#<%= txtbegintime.ClientID %>").val(begintime);
$("#<%= txtendtime.ClientID %>").val(endtime);
}
function Click_Cell(object) {
if (object.style.backgroundColor.toUpperCase() == ‘<%=indaycolor%>‘.toUpperCase())
object.style.backgroundColor = ‘<%=outdaycolor%>‘;
else
object.style.backgroundColor = ‘<%=indaycolor%>‘;
//数据格式采用ID:n,{ID:n....}(n双数上班,单数休息)
var innerstring;
var inners;
innerstring = inners = $("#<%= hidKey.ClientID %>").val();
//遍历ID找到是否存在该ID,如果有就修改VALUE,没有就添加VALUE=0
var arr = inners.split(",");
var arrtmp;
var re = /\d+/; //匹配id
var re1 = /:\w+/; //匹配n
var n, tmpstr;
var havefound = false; //找到了匹配项
for (var i = 0; i < arr.length; i++) {
arrtmp = arr[i].match(re);
if ((arrtmp != null) && (arrtmp[0] == object.id.replace("ctl00_ContentPlaceHolder1_", "")))//找到匹配项
{
n = arr[i].match(re1);
n = n[0].substr(1);
n = ":" + String(parseInt(n) + 1);
tmpstr = arr[i].replace(re1, n);
$("#<%= hidKey.ClientID %>").val(inners.replace(arr[i], tmpstr));
havefound = true;
break;
}
}
if (!havefound)//没有找到匹配项,添加字符串
{
if (object.style.backgroundColor.toUpperCase() == ‘<%=indaycolor%>‘.toUpperCase())
innerstring = object.id.replace("ctl00_ContentPlaceHolder1_", "") + ":0,";
else
innerstring = object.id.replace("ctl00_ContentPlaceHolder1_", "") + ":1,";
inners += innerstring;
$("#<%= hidKey.ClientID %>").val(inners);
}
}

function Top_Click(cellnumber) {
var table = document.getElementById("ctl00_ContentPlaceHolder1_daytable");
for (var i = 0; i < table.rows.length; i++) {
table.rows[i].cells[cellnumber].click();
}
}
function Query() {
$("#<%= btnQuery.ClientID%>").click();
}
function Add() {
$("#<%= btnAdd.ClientID%>").click();
}
// 取消
function BtnCancel() {
parent.closeiframe(‘年度排休设置‘);
}
</script>
<form id="ShowDay" method="post" runat="server">
<div id="query1" title="请选择年度排休日期" collapsible="true" style="padding: 1px; height: 56px"
class="easyui-panel" icon="icon-search">
<table cellpadding="0" cellspacing="0" width="100%" class="table">
<tr>
<td width="10%" class="ti_blue">
排休月份
</td>
<td width="13%">
<asp:TextBox ID="txtbegintime" runat="server" Width="90%" CssClass="Wdate" ForeColor="#4d6fc8"
onfocus="WdatePicker({dateFmt:‘yyyy-MM‘})"></asp:TextBox><span class="ti_blue">
</td>
<td width="10%" class="ti_blue">
<%--结束日期--%>
</td>
<td width="13%">
<asp:TextBox ID="txtendtime" runat="server" Width="90%" Visible="false" CssClass="Wdate"
ForeColor="#4d6fc8" onfocus="WdatePicker({dateFmt:‘yyyy-MM-dd‘,minDate:‘#F{$dp.$D(\‘ctl00$ContentPlaceHolder1$txtBeginTime\‘)}‘})"></asp:TextBox>
</td>
<td width="10%" class="ti_blue">
</td>
<td width="13%">
<%-- <asp:RadioButton ID="rbtnthisweek" onclick="quickseldate(‘week‘);" runat="server"
GroupName="quickdate" Text="本周"></asp:RadioButton><asp:RadioButton ID="rbtnthismonth"
onclick="quickseldate(‘month‘);" runat="server" GroupName="quickdate" Text="本月">
</asp:RadioButton>--%>
</td>
<td width="10%" align="right" style="padding-right: 10px">
<a href="#" class="easyui-linkbutton" iconcls="icon-search" onclick="Query();">查 询</a>
<asp:Button ID="btnQuery" runat="server" Style="display: none" OnClick="btnQuery_Click" />
</td>
</tr>
</table>
</div>
<div style="height: 1px">
</div>
<div id="query" title="年度排休信息设置" collapsible="true" style="padding: 1px; height: 280px;"
class="easyui-panel" icon="icon-edit">
<table id="daytable" cellspacing="0" cellpadding="0" width="100%" align="center"
border="1" runat="server" class="gbtext" style="border-collapse: collapse" bordercolor="#93bee2">
<tr height="30">
<td align="center" style="cursor: hand" onclick="Top_Click(0)" onmouseover="this.title=‘点击改变整列‘"
title="点击修改整列" bgcolor="#e8f4ff">
星期一
</td>
<td align="center" style="cursor: hand" onclick="Top_Click(1)" onmouseover="this.title=‘点击改变整列‘"
bgcolor="#e8f4ff">
星期二
</td>
<td align="center" style="cursor: hand" onclick="Top_Click(2)" onmouseover="this.title=‘点击改变整列‘"
bgcolor="#e8f4ff">
星期三
</td>
<td align="center" style="cursor: hand" onclick="Top_Click(3)" onmouseover="this.title=‘点击改变整列‘"
bgcolor="#e8f4ff">
星期四
</td>
<td align="center" style="cursor: hand" onclick="Top_Click(4)" onmouseover="this.title=‘点击改变整列‘"
bgcolor="#e8f4ff">
星期五
</td>
<td align="center" style="cursor: hand" onclick="Top_Click(5)" onmouseover="this.title=‘点击改变整列‘"
bgcolor="#e8f4ff">
星期六
</td>
<td align="center" style="cursor: hand" onclick="Top_Click(6)" onmouseover="this.title=‘点击改变整列‘"
bgcolor="#e8f4ff">
星期日
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse"
width="100%" height="35">
<tr>
<td class="GbText">
<table id="Table1" height="24" cellspacing="0" cellpadding="0" width="120" class="gbtext"
style="border-collapse: collapse" border="1" bordercolor="#e8e8e8">
<tr>
<td bgcolor="#EBF0F5" width="60" align="center">
工作日
</td>
<td bgcolor="#FFF0E0" width="60" align="center">
休息日
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div style="height: 1px">
</div>
<div id="help" title="年度排休信息操作说明" collapsible="true" style="padding: 1px; height: 80px"
class="easyui-panel" icon="icon-help">
<table cellpadding="0" cellspacing="0" width="100%" class="table">
<tr>
<td width="100%" class="td_left_noborder">
1、年度排休信息操作说明(点击休息日颜色变红,点击保存)。
</td>
</tr>
<tr>
<td width="100%" class="td_left_noborder">
2、单击第一行(星期),可以快速改变整列。
</td>
</tr>
</table>
</div>
<div id="tool" style="width: 300px; padding: 2px; margin: 0 auto">
<asp:HiddenField runat="server" ID="hidKey" />
<asp:Button ID="btnAdd" runat="server" Style="display: none" OnClick="btnAdd_Click" />
<a href="#" class="easyui-linkbutton" iconcls="icon-ok" id="add" onclick="Add();">保
存</a> <a href="#" class="easyui-linkbutton" iconcls="icon-undo" onclick="BtnCancel();">
取 消</a>
</div>
</form>
</asp:Content>

 

 

 

 

 

 

 

 

 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FencerSoft.DBUtility;
using System.Data.SqlClient;
using System.Data;
using FencerSoft.Web.Common;

namespace Fencer_OA.Zhxz.add
{
public partial class Ndpx_add : System.Web.UI.Page
{
protected string indaycolor;//应该出勤天数的背景色
protected System.Web.UI.WebControls.Button btnsubmit;
protected System.Web.UI.WebControls.Button lblMessage;
protected string outdaycolor;//无需出勤天数的背景色
private void Page_Load(object sender, System.EventArgs e)
{
indaycolor = "#EBF0F5";
outdaycolor = "#FFF0E0";
if (!Page.IsPostBack)
{
txtbegintime.Text = DateTime.Now.ToString("yyyy-MM");
string begintime;
begintime = (txtbegintime.Text.Trim() == "") ? DateTime.Now.ToString("yyyy-MM") : txtbegintime.Text.Trim().ToString();
//endtime = (txtendtime.Text.Trim() == null) ? DateTime.Now.ToShortDateString() : txtendtime.Text.Trim().ToString();
BindData(begintime);
}
}
/// <summary>
/// 绑定DataTable
/// </summary>
/// <param name="begintime"></param>
/// <param name="endtime">, string endtime</param>
private void BindData(string begintime)
{
int j = 0;
SqlDataReader dr = DbHelperSQL.ExecuteReader("select * from WorkAttendence where CONVERT(varchar(7),datetime,120) = ‘" + begintime + "‘");
bool outwhile = false;
while (!outwhile)
{
System.Web.UI.HtmlControls.HtmlTableRow row = new System.Web.UI.HtmlControls.HtmlTableRow();
row.Height = "30";
while (row.Cells.Count < 7)
{
if (!dr.Read())
{
//填补空余列
int blankcells = 7 - row.Cells.Count;
for (int i = 0; i < blankcells; i++)
{
System.Web.UI.HtmlControls.HtmlTableCell tmpcell = new System.Web.UI.HtmlControls.HtmlTableCell();
tmpcell.InnerHtml = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
row.Cells.Add(tmpcell);
}
daytable.Rows.Add(row);
outwhile = true;
break;
}
System.Web.UI.HtmlControls.HtmlTableCell col = new System.Web.UI.HtmlControls.HtmlTableCell();
switch (DateTime.Parse(dr[0].ToString()).DayOfWeek.ToString())
{
case "Monday": j = 1; break;
case "Tuesday": j = 2; break;
case "Wednesday": j = 3; break;
case "Thursday": j = 4; break;
case "Friday": j = 5; break;
case "Saturday": j = 6; break;
case "Sunday": j = 7; break;
default:
break;
}
col.ID = dr["id"].ToString();
col.Align = "center";
if (Convert.ToBoolean(dr["needduty"]) == true)
{
col.Style.Add("background-color", indaycolor);
}
else
{
col.Style.Add("background-color", outdaycolor);
}
//DateTime.Parse(dr["datetime"].ToString()).Month.ToString() + "-" +
col.InnerText = DateTime.Parse(dr["datetime"].ToString()).Month.ToString() + "月" + DateTime.Parse(dr["datetime"].ToString()).Day.ToString() + "号";

//如果当前日期紧接前面的日期就添加列
if ((row.Cells.Count + 1) == j)
{
col.Style.Add("cursor", "hand");
row.Cells.Add(col);
col.Attributes["onclick"] = "Click_Cell(this);";
}
else
{
int blankcell = j - row.Cells.Count - 1;
//补充缺掉的cell
if (blankcell > 0)
{
for (int k = 0; k < blankcell; k++)
{
System.Web.UI.HtmlControls.HtmlTableCell tmpcol = new System.Web.UI.HtmlControls.HtmlTableCell();
tmpcol.InnerText = "";
row.Cells.Add(tmpcol);
}
col.Style.Add("cursor", "hand");
row.Cells.Add(col);
col.Attributes["onclick"] = "Click_Cell(this);";
}
else
{
blankcell = j + 6 - row.Cells.Count;
for (int k = 0; k < blankcell; k++)
{
if (row.Cells.Count == 7)
{
daytable.Rows.Add(row);
}
else
{
System.Web.UI.HtmlControls.HtmlTableCell tmpcol = new System.Web.UI.HtmlControls.HtmlTableCell();
tmpcol.InnerText = "";
row.Cells.Add(tmpcol);
}
col.Style.Add("cursor", "hand");
row.Cells.Add(col);
col.Attributes["onclick"] = "if(this.style.backgroundColor==‘" + indaycolor + "‘) this.style.backgroundColor = ‘" + outdaycolor + "‘;else this.style.backgroundColor = ‘" + indaycolor + "‘;Click_Cell(this);this.blur();";
}
}

}
//添加完列判断是否需要添加行
if (row.Cells.Count == 7)
{
daytable.Rows.Add(row);
}
}
}
dr.Close();
}
/// <summary>
/// 点击查询 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnQuery_Click(object sender, EventArgs e)
{
//, endtime
string begintime;
begintime = (txtbegintime.Text.Trim() == "") ? DateTime.Now.ToString("yyyy-MM") : txtbegintime.Text.Trim().ToString();
//endtime = (txtendtime.Text.Trim() == null) ? DateTime.Now.ToShortDateString() : txtendtime.Text.Trim().ToString();
BindData(begintime);
}
/// <summary>
/// 新增到排休日到排休表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAdd_Click(object sender, EventArgs e)
{
string tmpstr = hidKey.Value;

string indaystr, outdaystr;
indaystr = outdaystr = "";
string[] arrdate = tmpstr.Split(‘,‘);
string[] tmp = new string[2];
for (int i = 0; i < arrdate.Length; i++)
{
if (arrdate[i].Trim() != "")
{
tmp = arrdate[i].Split(‘:‘);
if (Int32.Parse(tmp[1].ToString()) % 2 == 0) //偶数上班日期
indaystr = indaystr + tmp[0] + ",";
else
outdaystr = outdaystr + tmp[0] + ",";
}
}
outdaystr = (outdaystr.Length == 0) ? "" : outdaystr.Substring(0, outdaystr.Length - 1);
indaystr = (indaystr.Length == 0) ? "" : indaystr.Substring(0, indaystr.Length - 1);
try
{
if (indaystr != "")
{
DbHelperSQL.ExecuteSql("update WorkAttendence set needduty=1 where id in (" + indaystr + ")");
}
if (outdaystr != "")
{
DbHelperSQL.ExecuteSql("update WorkAttendence set needduty=0 where id in (" + outdaystr + ")");
}
string begintime;
begintime = (txtbegintime.Text.Trim() == "") ? DateTime.Now.ToString("yyyy-MM") : txtbegintime.Text.Trim().ToString();
//endtime = (txtendtime.Text.Trim() == null) ? DateTime.Now.ToShortDateString() : txtendtime.Text.Trim().ToString();
BindData(begintime);
MessageBox.Show(this, "年度排休设置成功!");
}
catch (Exception)
{
MessageBox.Show(this, "年度排休设置失败!");
}
}
}
}

节假日设置

原文:http://www.cnblogs.com/zcwry/p/jiejiari.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!