private void updateCurAttendType(string attendTypeName) { currentAttendType = Utils.getAttendType(attendTypeName); CurAttendTypeNameTextBox.Text = currentAttendType.AttendTypeName; CurAttendTypeTargetHourInTextBox.Text = currentAttendType.TargetHourIn.ToString(); CurAttendTypeTargetMinuteInTextBox.Text = currentAttendType.TargetMinuteIn.ToString(); CurAttendTypeShiftTimeTextBox.Text = currentAttendType.ShiftTime.ToString(); CurAttendTypeIsShiftCheckBox.Checked = currentAttendType.IsShift; }
private void DeleteButton_Click(object sender, EventArgs e) { if (currentAttendType != null) { Utils.deleteAttendType(currentAttendType.AttendTypeName); updateDataGridView(); currentAttendType = null; MessageBox.Show("Delete successfully."); } }
public static void updateAttendType(AttendType attendType) { XElement xAttenType = xeleAttendTypes.Elements().Where(x => x.Attribute("Name").Value == attendType.AttendTypeName).Single(); //拉姆达表达式 xAttenType.SetAttributeValue("Name", attendType.AttendTypeName); xAttenType.SetAttributeValue("TargetHourIn", attendType.TargetHourIn); xAttenType.SetAttributeValue("TargetMinuteIn", attendType.TargetMinuteIn); xAttenType.SetAttributeValue("ShiftTime", attendType.ShiftTime); xAttenType.SetAttributeValue("IsShift", attendType.IsShift); xConfigdoc.Save(sourcePath); }
public ActionResult Edit(AttendType obj) { try { NSession.Update(obj); NSession.Flush(); } catch (Exception ee) { return(Json(new { IsSuccess = false, ErrorMsg = "出错了" })); } return(Json(new { IsSuccess = true })); }
/// <summary> /// 根据Id获取 /// </summary> /// <param name="Id"></param> /// <returns></returns> public AttendType GetById(int Id) { AttendType obj = NSession.Get <AttendType>(Id); if (obj == null) { throw new Exception("返回实体为空"); } else { return(obj); } }
public JsonResult DeleteConfirmed(int id) { try { AttendType obj = GetById(id); NSession.Delete(obj); NSession.Flush(); } catch (Exception ee) { return(Json(new { IsSuccess = false, ErrorMsg = "出错了" })); } return(Json(new { IsSuccess = true })); }
public void NoAttend(DateTime LastAttend) { TimeSpan day = DateTime.Now.Date - LastAttend; for (int i = 1; i < day.Days; i++) { AttendType obj = new AttendType() { CurrentDate = DateTime.Now.Date.AddDays(-i), UserId = CurrentUser.Id, UserCode = CurrentUser.Code, RealName = CurrentUser.Realname }; NSession.Save(obj); NSession.Flush(); } }
private void NewButton_Click(object sender, EventArgs e) { if (checkNewAttendType()) { AttendType newEmployee = new AttendType() { TargetHourIn = _targetHourIn, AttendTypeName = AttendTypeNameTextBox.Text, TargetMinuteIn = _targetMinuteIn, IsShift = IsShiftCheckBox.Checked, ShiftTime = _shiftTime }; Utils.addAttendType(newEmployee); updateDataGridView(); } }
public static void addAttendType(AttendType attendType) { //在已存在的节点上添加属性和数据 XElement xAttendType = new XElement("attendType"); xAttendType.SetAttributeValue("Name", attendType.AttendTypeName); xAttendType.SetAttributeValue("IsShift", attendType.IsShift); xAttendType.SetAttributeValue("TargetHourIn", attendType.TargetHourIn); xAttendType.SetAttributeValue("TargetMinuteIn", attendType.TargetMinuteIn); xAttendType.SetAttributeValue("ShiftTime", attendType.ShiftTime); xAttendType.SetAttributeValue("StartDinnerBreakHour", attendType.StartDinnerBreakHour); xAttendType.SetAttributeValue("StartDinnerBreakMinute", attendType.StartDinnerBreakMinute); xAttendType.SetAttributeValue("DinnerBreakMinute", attendType.DinnerBreakMinute); xAttendType.SetAttributeValue("TempBreakMinute", attendType.TempBreakMinute); xeleEmployees.Add(xAttendType); xConfigdoc.Save(sourcePath); }
public static void initilizeOrReloadByLinq() { xConfigdoc = XDocument.Load(sourcePath); XElement xeleRoot = xConfigdoc.Root; xeleAttendTypes = xeleRoot.Element("attendTypes"); foreach (var xAttendType in xeleAttendTypes.Elements()) { var Name = xAttendType.Attribute("Name").Value; var IsShiftStr = xAttendType.Attribute("IsShift").Value; bool IsShift = false; bool.TryParse(IsShiftStr, out IsShift); var TargetHourInStr = xAttendType.Attribute("TargetHourIn").Value; int TargetHourIn = 9; int.TryParse(TargetHourInStr, out TargetHourIn); var TargetMinuteInStr = xAttendType.Attribute("TargetMinuteIn").Value; int TargetMinuteIn = 0; int.TryParse(TargetMinuteInStr, out TargetMinuteIn); var ShiftTimeStr = xAttendType.Attribute("ShiftTime").Value; int ShiftTime = 0; int.TryParse(ShiftTimeStr, out ShiftTime); var StartDinnerBreakHourStr = xAttendType.Attribute("StartDinnerBreakHour").Value; int StartDinnerBreakHour = 0; int.TryParse(StartDinnerBreakHourStr, out StartDinnerBreakHour); var StartDinnerBreakMinuteStr = xAttendType.Attribute("StartDinnerBreakMinute").Value; int StartDinnerBreakMinute = 0; int.TryParse(StartDinnerBreakMinuteStr, out StartDinnerBreakMinute); var DinnerBreakMinuteStr = xAttendType.Attribute("DinnerBreakMinute").Value; int DinnerBreakMinute = 0; int.TryParse(DinnerBreakMinuteStr, out DinnerBreakMinute); var TempBreakMinuteStr = xAttendType.Attribute("TempBreakMinute").Value; int TempBreakMinute = 0; int.TryParse(TempBreakMinuteStr, out TempBreakMinute); AttendType attendType = new AttendType() { AttendTypeName = Name, IsShift = IsShift, TargetHourIn = TargetHourIn, TargetMinuteIn = TargetMinuteIn, ShiftTime = ShiftTime, StartDinnerBreakHour = StartDinnerBreakHour, StartDinnerBreakMinute = StartDinnerBreakMinute, DinnerBreakMinute = DinnerBreakMinute, TempBreakMinute = TempBreakMinute }; attendTypes.Add(attendType); } xeleEmployees = xeleRoot.Element("employees"); foreach (var xEmployee in xeleEmployees.Elements()) { var EmployeeID = xEmployee.Attribute("EmployeeID").Value; var AttendTypeName = xEmployee.Attribute("AttendType").Value; var AgeStr = xEmployee.Attribute("Age").Value; int Age = 9; int.TryParse(AgeStr, out Age); var GenderStr = xEmployee.Attribute("Gender").Value; bool Gender = true; bool.TryParse(GenderStr, out Gender); var Name = xEmployee.Attribute("Name").Value; var AttendType = attendTypes.Where(a => a.AttendTypeName == AttendTypeName).FirstOrDefault(); Employee employee = new Employee() { EmployeeID = EmployeeID, AttendType = AttendType, Age = Age, Gender = Gender, Name = Name }; employees.Add(employee); } xExportFolderElement = xeleRoot.Element("exportPath"); exportPath = xExportFolderElement.Value; }
public static string GetName(AttendType attendType) { return(items[attendType].ToString()); }
public ActionResult Edit(int id) { AttendType obj = GetById(id); return(View(obj)); }
//签到操作 public JsonResult AttendOn(int id, string code = "") { string ip = GetIP(); DateTime AttentTime = DateTime.Now; int userid = CurrentUser.Id; string usercode = CurrentUser.Code; string realname = CurrentUser.Realname; if (code != "") { IList <UserType> users = NSession.CreateQuery("from UserType where Code='" + code + "'").List <UserType>(); if (users.Count > 0) { userid = users[0].Id; usercode = users[0].Code; realname = users[0].Realname; } else { return(Json(new { Msg = code + " 编号不存在!" }, JsonRequestBehavior.AllowGet)); } } AttendType obj = new AttendType() { CurrentDate = AttentTime.Date, UserId = userid, UserCode = usercode, RealName = realname }; try { IList <AttendType> list = NSession.CreateQuery("from AttendType where UserId='" + obj.UserId + "' and CurrentDate='" + obj.CurrentDate + "'").List <AttendType>(); if (IsOK(ip)) { //IList<AttendType> objList = NSession.CreateQuery("from AttendType " + " where UserId=\'" + obj.UserId + "\' order by CurrentDate desc ") //.List<AttendType>(); //if (objList.Count > 0) //{ // //NoAttend(objList[0].CurrentDate); //} if (list.Count > 0) { obj = list[0]; } obj.IP = ip; } else { return(Json(new { Msg = "请使用公司网络打卡!" }, JsonRequestBehavior.AllowGet)); } switch (id) { case 0: if (string.IsNullOrEmpty(obj.AMStart)) { obj.AMStart = AttentTime.ToString("yyyy-MM-dd HH:mm:ss"); } else { return(Json(new { Msg = "请不要重复打卡!" }, JsonRequestBehavior.AllowGet)); } break; case 1: if (string.IsNullOrEmpty(obj.AMEnd)) { obj.AMEnd = AttentTime.ToString("yyyy-MM-dd HH:mm:ss"); } else { return(Json(new { Msg = "请不要重复打卡!" }, JsonRequestBehavior.AllowGet)); } break; case 2: if (string.IsNullOrEmpty(obj.PMStart)) { obj.PMStart = AttentTime.ToString("yyyy-MM-dd HH:mm:ss"); } else { return(Json(new { Msg = "请不要重复打卡!" }, JsonRequestBehavior.AllowGet)); } break; case 3: if (string.IsNullOrEmpty(obj.PMEnd)) { obj.PMEnd = AttentTime.ToString("yyyy-MM-dd HH:mm:ss"); } else { return(Json(new { Msg = "请不要重复打卡!" }, JsonRequestBehavior.AllowGet)); } break; } NSession.SaveOrUpdate(obj); NSession.Flush(); } catch (Exception ee) { return(Json(new { Msg = "出错了" }, JsonRequestBehavior.AllowGet)); } return(Json(new { Msg = obj.RealName + " 签到成功:" + AttentTime.ToString("yyyy-MM-dd HH:mm:ss") }, JsonRequestBehavior.AllowGet)); }