public bool judgeWorkDay(DateTime day, H3.IEngine engine) { List < string > allholidy= getAllHoliday(engine); string dayTime = day.ToString("yyyyMMdd"); //判断是否是工作日 if(allholidy.Contains(dayTime)) { return false; } return true; } public List < string > getAllHoliday(H3.IEngine engine) { string sql = " SELECT * FROM i_D002033holiday "; List < string > allholidy = new List<string>(); System.Data.DataTable dt = engine.Query.QueryTable(sql, null); if(dt.Rows.Count != 0) { for(int i = 0;i < dt.Rows.Count; i++) { string yearMonth = dt.Rows[i]["yearMonth"] + string.Empty; string day = dt.Rows[i]["day"] + string.Empty; allholidy.Add(yearMonth + day); } } return allholidy; }
if(actionName == "Submit" && this.Request.BizObject["Checkintype"] + string.Empty == "上班打卡") { //考勤明细的构建schema H3.DataModel.BizObjectSchema schema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D002033attendanceDetail"); //new 一个考勤明细的对象 H3.DataModel.BizObject targetBo = new H3.DataModel.BizObject(this.Engine, schema, this.Request.UserContext.UserId); //获取到考勤打卡的对象信息 H3.DataModel.BizObject targetBo2 = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId, this.Engine, "D002033Clockin", this.Request.BizObjectId, false); //申请人 targetBo["employees"] = targetBo2["Signinperson"] + string.Empty; DateTime dtNow = Convert.ToDateTime(targetBo2["Checkinperiod"] + string.Empty); //截取当前日期为时分格式 string now = dtNow.Year + "/" + dtNow.Month + "/" + dtNow.Day; //申请日期 targetBo["dateTime"] = now + string.Empty; //上班时间 targetBo["workTime"] = targetBo2["Checkinperiod"] + string.Empty; DateTime Checkinperiods = Convert.ToDateTime(targetBo2["Checkinperiod"]); if(!judgeWorkDay(Checkinperiods, this.Engine)) { targetBo["workhours"] = 0; targetBo["totalTime"] = 0; } else { targetBo["workhours"] = 8; targetBo["totalTime"] = 8; } //目标表单创建 targetBo.Create(); }
if(switchOT && Checkintype == "下班打卡")//&& { // string onTimeSelect = masterBo["onTimeSelect"] + string.Empty; // 工作日加班开始时间 DateTime swo = DateTime.Parse(Checkinperiod.Year + "/" + Checkinperiod.Month + "/" + Checkinperiod.Day + " 18:00:00"); // if(!string.IsNullOrEmpty(onTimeSelect)) // { if(!judgeWorkDay(Checkinperiod, this.Engine)) { // H3.DataModel.BizObject onTimeBo = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId, this.Engine, this.Request.SchemaCode, onTimeSelect, false); //节假日加班开始时间 swo = Convert.ToDateTime(Checkinperiod.Year + "/" + Checkinperiod.Month + "/" + Checkinperiod.Day + " 09:00:00"); }
后端,动态自动设定打卡状态
if(actionName == "GetList") { // 获取本主表 // H3.DataModel.BizObject childBoArr = this.Request.BizObject; //获取当前日期 DateTime dtNow = Convert.ToDateTime(this.Request["CheckinperiodBy"] + string.Empty); //截取当前日期为时分格式 string now = dtNow.Hour + ":" + dtNow.Minute; //当前时间 DateTime dt1 = Convert.ToDateTime(now); response.ReturnData = new Dictionary<string, object>(); DateTime dtm1 = Convert.ToDateTime("06:00"); DateTime dtm2 = Convert.ToDateTime("12:00"); DateTime dtn1 = Convert.ToDateTime("12:01"); DateTime dtn2 = Convert.ToDateTime("23:59"); if(DateTime.Compare(dt1, dtm1) > 0 && DateTime.Compare(dt1, dtm2) < 0) { // childBoArr["Checkintype"] = "上班打卡"; // childBoArr.Update(); response.ReturnData.Add("result", 1); } else if(DateTime.Compare(dt1, dtn1) > 0 && DateTime.Compare(dt1, dtn2) < 0) { // childBoArr["Checkintype"] = "下班打卡"; // childBoArr.Update(); response.ReturnData.Add("result", 2); } }
// 加载事件 OnLoad: function() { // _this.Checkinperiod.BindChange("onChange",function(data){ // var dtNow=_this.Checkinperiod.GetValue(); // _this.Checkintype.SetValue(); // }) judgeTime(); _this.Checkinperiod.BindChange( "OnChange", function( da ) { judgeTime(); })
function judgeTime() { $.SmartForm.PostForm( "GetList", { CheckinperiodBy: _this.Checkinperiod.GetValue() }, function( data ) { debugger if( data != undefined ) { var result = data.ReturnData[ "result" ]; // alert( result ); if( result == 1 ) { _this.Checkintype.SetValue( "上班打卡" ); } else if( result == 2 ) { _this.Checkintype.SetValue( "下班打卡" ); } } })
氚云数据默认显示日期所有格式,如果要用日期查询,则目标表要截取日期格式
string F0000006 = this.Request.BizObject["F0000006"] + string.Empty;//名字 string F0000003 = this.Request.BizObject["F0000003"] + string.Empty;//下班时间 DateTime dtNow = Convert.ToDateTime(this.Request.BizObject["F0000003"] + string.Empty); //截取当前日期为时分格式 string now = dtNow.Year + "/" + dtNow.Month + "/" + dtNow.Day + " 00:00:00"; double F0000004 = Convert.ToDouble(this.Request.BizObject["F0000004"] + string.Empty);//时长 //考勤明细的构建schema H3.DataModel.BizObjectSchema schema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D002033attendanceDetail"); //new 一个库存单的对象 H3.DataModel.BizObject targetBo = new H3.DataModel.BizObject(this.Engine, schema, this.Request.UserContext.UserId); string sqlselect = "select * from i_D002033attendanceDetail where dateTime = '" + now + "' and employees='" + F0000006 + "'"; System.Data.DataTable tableSelect = this.Engine.Query.QueryTable(sqlselect, null);