/// <summary> /// 获取单条记录 /// </summary> /// <returns></returns> public static OD_USER_Model getModel(OD_USER_SW sw) { OD_USER_Model m = new OD_USER_Model(); DataTable dt = BaseDT.OD_USER.getDT(sw); DataTable dtUser = BaseDT.T_SYSSEC_USER.getDT(new T_SYSSEC_IPSUSER_SW { curOrgNo = SystemCls.getCurUserOrgNo() }); if (dt.Rows.Count > 0) { int i = 0; m.ODUID = dt.Rows[i]["ODUID"].ToString(); m.ONDUTYDATE = PublicClassLibrary.ClsSwitch.SwitDate(dt.Rows[i]["ONDUTYDATE"].ToString()); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.ONDUTYUSERTYPE = dt.Rows[i]["ONDUTYUSERTYPE"].ToString(); m.ONDUTYUSERID = dt.Rows[i]["ONDUTYUSERID"].ToString(); m.ISATTENDED = dt.Rows[i]["ISATTENDED"].ToString(); m.ATTENDEDTIME = PublicClassLibrary.ClsSwitch.SwitTM(dt.Rows[i]["ATTENDEDTIME"].ToString()); m.USERNAME = BaseDT.T_SYSSEC_USER.getNameByUserList(dtUser, m.ONDUTYUSERID); } dt.Clear(); dt.Dispose(); dtUser.Clear(); dtUser.Dispose(); return(m); }
/// <summary> /// 获取列表 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static IEnumerable <OD_USER_Model> getListModel(OD_USER_SW sw) { var result = new List <OD_USER_Model>(); DataTable dt = BaseDT.OD_USER.getDT(sw); DataTable dtUser = BaseDT.T_SYSSEC_USER.getDT(new T_SYSSEC_IPSUSER_SW { curOrgNo = sw.BYORGNO }); DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { }); for (int i = 0; i < dt.Rows.Count; i++) { OD_USER_Model m = new OD_USER_Model(); m.ODUID = dt.Rows[i]["ODUID"].ToString(); m.ONDUTYDATE = PublicClassLibrary.ClsSwitch.SwitDate(dt.Rows[i]["ONDUTYDATE"].ToString()); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.ONDUTYUSERTYPE = dt.Rows[i]["ONDUTYUSERTYPE"].ToString(); m.ONDUTYUSERID = dt.Rows[i]["ONDUTYUSERID"].ToString(); m.ISATTENDED = dt.Rows[i]["ISATTENDED"].ToString(); m.ATTENDEDTIME = PublicClassLibrary.ClsSwitch.SwitTM(dt.Rows[i]["ATTENDEDTIME"].ToString()); m.USERNAME = BaseDT.T_SYSSEC_USER.getNameByUserList(dtUser, m.ONDUTYUSERID); m.ORGNAME = BaseDT.T_SYS_ORG.getName(dtORG, dt.Rows[i]["BYORGNO"].ToString()); result.Add(m); } dt.Clear(); dt.Dispose(); dtUser.Clear(); dtUser.Dispose(); dtORG.Clear(); dtORG.Dispose(); return(result); }
/// <summary> /// 周末值班统计 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static IEnumerable <OD_USER_Model> getWeekCountListModel(OD_USER_SW sw) { var result = new List <OD_USER_Model>(); DataTable dt = BaseDT.OD_USER.getWeekDT(sw); DataTable dtU = BaseDT.T_SYSSEC_USER.getDT(new T_SYSSEC_IPSUSER_SW { }); //获取所有系统用户 DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { TopORGNO = sw.curOrgNo, OnlyGetShiXian = "1" }); //获取单位 for (int i = 0; i < dtORG.Rows.Count; i++) { string orgNo = dtORG.Rows[i]["ORGNO"].ToString(); //编码 string orgName = dtORG.Rows[i]["ORGNAME"].ToString(); //名称 DataRow[] dr = dtU.Select("ORGNO='" + orgNo + "'"); for (int k = 0; k < dr.Length; k++) { string uid = dr[k]["USERID"].ToString(); string uName = BaseDT.T_SYSSEC_USER.getNameByUserList(dtU, uid); string count = BaseDT.OD_USER.getCountByDT(dt, uid); OD_USER_Model m = new OD_USER_Model(); m.ORGNAME = orgName; m.USERNAME = uName; m.weekCount = count; if (count != "0") { result.Add(m); } } } return(result); }
/// <summary> /// 排班表向下复制功能 /// </summary> /// <param name="m">值班日期</param> /// <returns></returns> public static Message Copy(OD_USER_Model m) { DateTime dt = Convert.ToDateTime(m.ONDUTYDATE); StringBuilder sbDel = new StringBuilder(); sbDel.AppendFormat("delete OD_USER where ONDUTYDATE='{0}'", dt.AddDays(1).ToString("yyyy-MM-dd")); sbDel.AppendFormat(" and BYORGNO='{0}'", m.BYORGNO); //先删除要复制的这天的记录 DataBaseClass.ExeSql(sbDel.ToString()); sbDel.Clear(); StringBuilder sb = new StringBuilder(); sb.AppendFormat("insert OD_USER(OD_TYPEID,ONDUTYDATE,BYORGNO,ONDUTYUSERTYPE,ONDUTYUSERID,ISATTENDED)"); sb.AppendFormat("select OD_TYPEID,'{0}',BYORGNO,ONDUTYUSERTYPE,ONDUTYUSERID,'0'as ISATTENDED from OD_USER", dt.AddDays(1).ToString("yyyy-MM-dd")); sb.AppendFormat(" where ONDUTYDATE='{0}'", ClsSql.EncodeSql(m.ONDUTYDATE)); sb.AppendFormat(" and BYORGNO='{0}'", ClsSql.EncodeSql(m.BYORGNO)); bool bln = DataBaseClass.ExeSql(sb.ToString()); if (bln == true) { return(new Message(true, "复制成功!", "")); } else { return(new Message(false, "复制失败!", "")); } }
/// <summary> /// 获取下一班次值班员情况 /// </summary> /// <param name="sw"></param> /// <returns></returns> public static IEnumerable <OD_USER_Model> getNextClassListModel(OD_USER_SW sw) { int classID = int.Parse(sw.ONDUTYUSERTYPE);//当前班次 switch (classID) { case 1: sw.ONDUTYUSERTYPE = "2"; break; case 2: sw.ONDUTYUSERTYPE = "3"; break; default: sw.ONDUTYUSERTYPE = "1"; sw.ONDUTYDATE = PublicClassLibrary.ClsSwitch.SwitDate(Convert.ToDateTime(sw.ONDUTYDATE).AddDays(1)); break; } var result = new List <OD_USER_Model>(); DataTable dt = BaseDT.OD_USER.getDT(sw); DataTable dtUser = BaseDT.T_SYSSEC_USER.getDT(new T_SYSSEC_IPSUSER_SW { curOrgNo = sw.BYORGNO }); DataTable dtORG = BaseDT.T_SYS_ORG.getDT(new T_SYS_ORGSW { }); for (int i = 0; i < dt.Rows.Count; i++) { OD_USER_Model m = new OD_USER_Model(); m.ODUID = dt.Rows[i]["ODUID"].ToString(); m.ONDUTYDATE = PublicClassLibrary.ClsSwitch.SwitDate(dt.Rows[i]["ONDUTYDATE"].ToString()); m.BYORGNO = dt.Rows[i]["BYORGNO"].ToString(); m.ONDUTYUSERTYPE = dt.Rows[i]["ONDUTYUSERTYPE"].ToString(); m.ONDUTYUSERID = dt.Rows[i]["ONDUTYUSERID"].ToString(); m.ISATTENDED = dt.Rows[i]["ISATTENDED"].ToString(); m.ATTENDEDTIME = PublicClassLibrary.ClsSwitch.SwitTM(dt.Rows[i]["ATTENDEDTIME"].ToString()); m.USERNAME = BaseDT.T_SYSSEC_USER.getNameByUserList(dtUser, m.ONDUTYUSERID); m.ORGNAME = BaseDT.T_SYS_ORG.getName(dtORG, dt.Rows[i]["BYORGNO"].ToString()); result.Add(m); } dt.Clear(); dt.Dispose(); dtUser.Clear(); dtUser.Dispose(); dtORG.Clear(); dtORG.Dispose(); return(result); }
/// <summary> /// 管理 /// </summary> /// <param name="m">m</param> /// <returns></returns> public static Message Manager(OD_USER_Model m) { if (m.opMethod == "Copy") { return(BaseDT.OD_USER.Copy(m)); } if (m.opMethod == "Add") { return(BaseDT.OD_USER.Add(m)); } if (m.opMethod == "Sign") { return(BaseDT.OD_USER.Sign(m)); } return(new Message(false, "无效操作", "")); }
/// <summary> /// 签到 /// </summary> /// <param name="m">m</param> /// <returns></returns> public static Message Sign(OD_USER_Model m) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("update OD_USER set"); sb.AppendFormat(" ISATTENDED='{0}'", ClsSql.EncodeSql("1")); sb.AppendFormat(" ,ATTENDEDTIME='{0}'", PublicClassLibrary.ClsSwitch.SwitTM(DateTime.Now)); sb.AppendFormat(" where 1=1"); sb.AppendFormat(" AND ONDUTYDATE='{0}'", ClsSql.EncodeSql(m.ONDUTYDATE)); sb.AppendFormat(" AND BYORGNO='{0}'", ClsSql.EncodeSql(m.BYORGNO)); sb.AppendFormat(" AND ONDUTYUSERID='{0}'", ClsSql.EncodeSql(m.ONDUTYUSERID)); sb.AppendFormat(" AND ONDUTYUSERTYPE='{0}'", ClsSql.EncodeSql(m.ONDUTYUSERTYPE)); bool b = DataBaseClass.ExeSql(sb.ToString()); if (b) { return(new Message(true, "签到成功", "")); } else { return(new Message(false, "签到失败", "")); } }
/// <summary> /// 排班表添加方法 /// </summary> /// <param name="m"></param> /// <returns></returns> public static Message Add(OD_USER_Model m) { //先删除 if (1 == 1) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("delete from OD_USER");//(OD_TYPEID, ONDUTYDATE, BYORGNO, ONDUTYUSERTYPE, ONDUTYUSERID, ISATTENDED)"); sb.AppendFormat(" where BYORGNO= '{0}'", m.BYORGNO); sb.AppendFormat(" and OD_TYPEID= '{0}'", m.OD_TYPEID); sb.AppendFormat(" and ONDUTYUSERTYPE= '{0}'", m.ONDUTYUSERTYPE); sb.AppendFormat(" and ONDUTYDATE>='{0}'", m.dateBegin); sb.AppendFormat(" and ONDUTYDATE<='{0}'", m.dateEnd); bool bln = DataBaseClass.ExeSql(sb.ToString()); } DateTime dtbeg = Convert.ToDateTime(m.dateBegin); DateTime dtend = Convert.ToDateTime(m.dateEnd); TimeSpan ts = dtend.Subtract(dtbeg); //判断下相差多少天 if (string.IsNullOrEmpty(m.ONDUTYUSERID) == false) //插入 { string[] arr = m.ONDUTYUSERID.Split(','); for (int i = 0; i < arr.Length; i++)//循环操作 { if (arr[i].Length > 0) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("INSERT INTO OD_USER(OD_TYPEID, ONDUTYDATE, BYORGNO, ONDUTYUSERTYPE, ONDUTYUSERID, ISATTENDED)"); sb.AppendFormat(" select '{0}'", m.OD_TYPEID); sb.AppendFormat(",ONDUTYDATE"); sb.AppendFormat(", '{0}'", m.BYORGNO); sb.AppendFormat(", '{0}'", m.ONDUTYUSERTYPE); sb.AppendFormat(", '{0}'", arr[i]); sb.AppendFormat(", '0'"); sb.AppendFormat(" from OD_DATE"); sb.AppendFormat(" where OD_TYPEID='{0}'", m.OD_TYPEID); sb.AppendFormat(" and ONDUTYDATE>='{0}'", m.dateBegin); sb.AppendFormat(" and ONDUTYDATE<='{0}'", m.dateEnd); //sb.AppendFormat("("); //sb.AppendFormat("'{0}'", m.OD_TYPEID); //sb.AppendFormat(",'{0}'", m.OD_TYPEID); //sb.AppendFormat("'{0}'", m.OD_TYPEID); //sb.AppendFormat("'{0}'", m.OD_TYPEID); //sb.AppendFormat(")"); bool bln = DataBaseClass.ExeSql(sb.ToString()); } } } //if (bln == true) return(new Message(true, "操作成功!", ts.Days.ToString())); //else // return new Message(false, "添加失败,请检查各输入框是否正确!", ""); //StringBuilder sb = new StringBuilder(); //sb.AppendFormat("INSERT INTO OD_USER(ONDUTYDATE, BYORGNO,ONDUTYUSERTYPE,ONDUTYUSERID,ISATTENDED,ATTENDEDTIME )"); //sb.AppendFormat("VALUES("); //sb.AppendFormat("'{0}'", ClsSql.EncodeSql(m.ONDUTYDATE)); //sb.AppendFormat(",'{0}'", ClsSql.EncodeSql(m.BYORGNO)); //sb.AppendFormat(",'{0}'", ClsSql.EncodeSql(m.ONDUTYUSERTYPE)); //sb.AppendFormat(",'{0}'", ClsSql.EncodeSql(m.ONDUTYUSERID)); //if (string.IsNullOrEmpty(m.ISATTENDED) == true)//是否签到,默认为0 未签到 // m.ISATTENDED = "0"; //sb.AppendFormat(",'{0}'", ClsSql.EncodeSql(m.ISATTENDED)); //if (string.IsNullOrEmpty(m.ATTENDEDTIME) == true) // sb.AppendFormat(",null"); //else // sb.AppendFormat(",'{0}'", ClsSql.EncodeSql(m.ATTENDEDTIME)); //sb.AppendFormat(")"); //bool bln = DataBaseClass.ExeSql(sb.ToString()); //if (bln == true) // return new Message(true, "添加成功!", ""); //else // return new Message(false, "添加失败,请检查各输入框是否正确!", ""); }