private void Create() { string Year = Request["Year"]; string Month = Request["Month"]; string day = Request["day"]; string SignType = Request["SignType"]; string ProjectId = Request["ProjectId"]; string UserId = Request["UserId"]; string UserName = Request["UserName"]; string Attachment = Request["Attachment"]; string Remark = Request["Remark"]; string Id = Request["Id"]; Project ProEnt = Project.Find(ProjectId); //查询是否存在该项目该年此月份的考勤 sql = @"select * from NCRL_SP..ProjectAttendance where Year='" + Convert.ToInt32(Year) + "' and Month='" + Convert.ToInt32(Month) + "' and ProjectId='" + ProjectId + "'"; DataTable dt = DataHelper.QueryDataTable(sql); //查询是否存在该部门本该年此月份的考勤 sql = @"select Id from NCRL_SP..DeptAttendance where Year='" + Convert.ToInt32(Year) + "'and Month='" + Convert.ToInt32(Month) + "' and BelongDeptId ='" + ProEnt.BelongDeptId + "'"; DataTable da = DataHelper.QueryDataTable(sql); //查询本公司是否存在该年此月份的考勤 sql = @"select * from NCRL_SP..CmpAttendance where Year='" + Convert.ToInt32(Year) + "'and Month='" + Convert.ToInt32(Month) + "'"; DataTable ca = DataHelper.QueryDataTable(sql); if (string.IsNullOrEmpty(Id)) { if (dt.Rows.Count > 0) { return; } Pent = new ProjectAttendance(); Pent.Attachment = Attachment; Pent.Remark = Remark; Pent.ProjectId = ProjectId; Pent.ProjectName = ProEnt.ProjectName; Pent.Year = Convert.ToInt32(Year); Pent.Month = Convert.ToInt32(Month); Pent.PManagerId = ProEnt.PManagerId; Pent.PManagerName = ProEnt.PManagerName; Pent.BelongDeptId = ProEnt.BelongDeptId; Pent.BelongDeptName = ProEnt.BelongDeptName; Pent.CreateId = WebPortalService.CurrentUserInfo.UserID; Pent.CreateName = WebPortalService.CurrentUserInfo.Name; Pent.CreateTime = DateTime.Now; Pent.DoCreate(); if (da.Rows.Count <= 0) { dent = new DeptAttendance(); dent.Year = Convert.ToInt32(Year); dent.Month = Convert.ToInt32(Month); dent.BelongDeptId = Pent.BelongDeptId; dent.BelongDeptName = Pent.BelongDeptName; dent.DoCreate(); } if (ca.Rows.Count <= 0) { cent = new CmpAttendance(); cent.Year = Convert.ToInt32(Year); cent.Month = Convert.ToInt32(Month); cent.DoCreate(); } } else { Pent = ProjectAttendance.Find(Id); if (Pent.Attachment != Attachment || Pent.Remark != Remark) { Pent.Attachment = Attachment; Pent.Remark = Remark; Pent.DoUpdate(); } } sql = "select * from NCRL_SP..ProjectAttendanceDetail where UserId='" + UserId + "'and CONVERT(varchar(10), AttendanceDate,120)='" + Convert.ToDateTime(Year + "-" + Month + "-" + day).ToString("yyyy-MM-dd") + "' and ProjectAttendanceId<>'" + Id + "' or ProjectAttendanceId is null "; IList <EasyDictionary> dicss = DataHelper.QueryDictList(sql); if (dicss.Count > 0) { ents = ProjectAttendanceDetail.Find(dicss[0].Get <string>("Id")); ents.AttendanceType = SignType; if (!string.IsNullOrEmpty(Id)) { ents.ProjectAttendanceId = Id; } else { ents.ProjectAttendanceId = Pent.Id; } ents.Description = ""; ents.DoUpdate(); if (!string.IsNullOrEmpty(Id)) { Response.Write("{success: true ,id:'" + Id + "'}"); Response.End(); return; } Response.Write("{success: true ,id:'" + Pent.Id + "'}"); Response.End(); return; } sql = "select * from NCRL_SP..ProjectAttendanceDetail where UserId='" + UserId + "'and CONVERT(varchar(10), AttendanceDate,120)='" + Convert.ToDateTime(Year + "-" + Month + "-" + day).ToString("yyyy-MM-dd") + "' and ProjectAttendanceId='" + Id + "'"; dicss = DataHelper.QueryDictList(sql); if (dicss.Count > 0) { ents = ProjectAttendanceDetail.Find(dicss[0].Get <string>("Id")); if (ents.AttendanceType != SignType) { ents.AttendanceType = SignType; } else { sql = "delete NCRL_SP..ProjectAttendanceDetail where UserId='" + UserId + "'and CONVERT(varchar(10), AttendanceDate,120)='" + Convert.ToDateTime(Year + "-" + Month + "-" + day).ToString("yyyy-MM-dd") + "' and ProjectAttendanceId='" + Id + "'"; DataHelper.ExecSql(sql); Response.Write("{success: true ,id:'" + Id + "'}"); Response.End(); return; } ents.CreateTime = System.DateTime.Now; ents.DoUpdate(); } else { ents = new ProjectAttendanceDetail(); ents.UserId = UserId; ents.UserName = UserName; if (!string.IsNullOrEmpty(Id)) { ents.ProjectAttendanceId = Id; } else { ents.ProjectAttendanceId = Pent.Id; } ents.AttendanceType = SignType; ents.AttendanceDate = Convert.ToDateTime(Year + "-" + Month + "-" + day); ents.CreateId = WebPortalService.CurrentUserInfo.UserID; ents.CreateName = WebPortalService.CurrentUserInfo.Name; ents.CreateTime = DateTime.Now; ents.DoCreate(); } if (!string.IsNullOrEmpty(Id)) { Response.Write("{success: true ,id:'" + Id + "'}"); Response.End(); return; } Response.Write("{success: true ,id:'" + Pent.Id + "'}"); Response.End(); }
private void Create() { string Year = Request["Year"]; string Month = Request["Month"]; string day = Request["day"]; string UserId = Request["UserId"]; string UserName = Request["UserName"]; string SignType = Request["SignType"]; sql = "select * from NCRL_SP..CmpAttendance where Year =" + Year + " and Month= " + Month; Cmps = DataHelper.QueryDictList(sql); string ComId; if (Cmps.Count <= 0) { Cent = new CmpAttendance(); Cent.Year = Convert.ToInt32(Year); Cent.Month = Convert.ToInt32(Month); Cent.DoCreate(); ComId = Cent.Id; } else { ComId = Cmps[0].Get <string>("Id"); } sql = "select * from NCRL_SP..ProjectAttendanceDetail where UserId='" + UserId + "'and CONVERT(varchar(10), AttendanceDate,120)='" + Convert.ToDateTime(Year + "-" + Month + "-" + day).ToString("yyyy-MM-dd") + "' and ProjectAttendanceId='" + ComId + "'"; IList <EasyDictionary> dicss = DataHelper.QueryDictList(sql); if (dicss.Count > 0) { Pdent = ProjectAttendanceDetail.Find(dicss[0].Get <string>("Id")); if (Pdent.AttendanceType != SignType) { Pdent.AttendanceType = SignType; } else { sql = "delete NCRL_SP..ProjectAttendanceDetail where UserId='" + UserId + "'and CONVERT(varchar(10), AttendanceDate,120)='" + Convert.ToDateTime(Year + "-" + Month + "-" + day).ToString("yyyy-MM-dd") + "' and ProjectAttendanceId='" + ComId + "'"; DataHelper.ExecSql(sql); return; } Pdent.CreateTime = System.DateTime.Now; Pdent.DoUpdate(); } else { Pdent = new ProjectAttendanceDetail(); Pdent.UserId = UserId; Pdent.UserName = UserName; Pdent.ProjectAttendanceId = ComId; Pdent.AttendanceType = SignType; Pdent.AttendanceDate = Convert.ToDateTime(Year + "-" + Month + "-" + day); Pdent.CreateId = WebPortalService.CurrentUserInfo.UserID; Pdent.CreateName = WebPortalService.CurrentUserInfo.Name; Pdent.CreateTime = DateTime.Now; Pdent.Description = "非项目人员考勤"; Pdent.DoCreate(); } Response.Write("{success: true ,ComId:'" + ComId + "'}"); Response.End(); }