public bool GetUserGroupByID(ref UserGroupInfo model, UserInfo user, ref string strError) { try { using (SqlDataReader dr = _db.GetUserGroupByID(model)) { if (dr.Read()) { model = (GetModelFromDataReader(dr)); return(true); } else { strError = "找不到任何数据"; return(false); } } } catch (Exception ex) { strError = ex.Message; return(false); } finally { } }
public bool GetUserGroupListByPage(ref List <UserGroupInfo> modelList, UserGroupInfo model, ref DividPage page, UserInfo user, ref string strError) { if (page == null) { page = new DividPage(); } List <UserGroupInfo> lstModel = new List <UserGroupInfo>(); try { using (SqlDataReader dr = Common_DB.QueryByDividPage(ref page, "V_UserGroup", GetFilterSql(model, user), "*", "Order By UserGroupType,UserGroupNo,ID Desc")) { while (dr.Read()) { lstModel.Add(GetModelFromDataReader(dr)); } } modelList = lstModel; return(true); } catch (Exception ex) { strError = ex.Message; return(false); } finally { } }
private UserGroupInfo GetModelFromDataReader(SqlDataReader dr) { UserGroupInfo model = new UserGroupInfo(); model.ID = dr["ID"].ToInt32(); model.UserGroupNo = dr["UserGroupNo"].ToDBString(); model.UserGroupName = dr["UserGroupName"].ToDBString(); model.UserGroupAbbName = dr["UserGroupAbbName"].ToDBString(); model.UserGroupType = dr["UserGroupType"].ToInt32(); model.UserGroupStatus = dr["UserGroupStatus"].ToInt32(); model.Description = dr["Description"].ToDBString(); model.IsDel = dr["ISDEL"].ToInt32(); model.Creater = dr["CREATER"].ToDBString(); model.CreateTime = dr["CREATETIME"].ToDateTime(); model.Modifyer = dr["MODIFYER"].ToDBString(); model.ModifyTime = dr["MODIFYTIME"].ToDateTimeNull(); if (Common_Func.readerExists(dr, "IsChecked")) { model.BIsChecked = dr["IsChecked"].ToBoolean(); } if (Common_Func.readerExists(dr, "StrUserGroupType")) { model.StrUserGroupType = dr["StrUserGroupType"].ToDBString(); } if (Common_Func.readerExists(dr, "StrUserGroupStatus")) { model.StrUserGroupStatus = dr["StrUserGroupStatus"].ToDBString(); } return(model); }
public SqlDataReader GetUserGroupByID(UserGroupInfo model) { string strSql = string.Empty; strSql = string.Format("SELECT * FROM T_UserGroup WHERE ID = {0}", model.ID); return(OperationSql.ExecuteReader(CommandType.Text, strSql, null)); }
private SqlParameter[] GetParameterFromModel(UserGroupInfo model) { int i; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000), new SqlParameter("@v_ID", model.ID.ToSqlValue()), new SqlParameter("@v_UserGroupNo", model.UserGroupNo.ToSqlValue()), new SqlParameter("@v_UserGroupName", model.UserGroupName.ToSqlValue()), new SqlParameter("@v_UserGroupAbbName", model.UserGroupAbbName.ToSqlValue()), new SqlParameter("@v_UserGroupType", model.UserGroupType.ToSqlValue()), new SqlParameter("@v_UserGroupStatus", model.UserGroupStatus.ToSqlValue()), new SqlParameter("@v_Description", model.Description.ToSqlValue()), new SqlParameter("@v_IsDel", model.IsDel.ToSqlValue()), new SqlParameter("@v_Creater", model.Creater.ToSqlValue()), new SqlParameter("@v_CreateTime", model.CreateTime.ToSqlValue()), new SqlParameter("@v_Modifyer", model.Modifyer.ToSqlValue()), new SqlParameter("@v_ModifyTime", model.ModifyTime.ToSqlValue()), }; i = 0; param[i++].Direction = ParameterDirection.Output; param[i++].Direction = ParameterDirection.InputOutput; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.InputOutput; param[i++].Direction = ParameterDirection.Input; param[i++].Direction = ParameterDirection.InputOutput; i = 0; param[i++].Size = 1000; param[i++].Size = 18; param[i++].Size = 20; param[i++].Size = 50; param[i++].Size = 50; param[i++].Size = 18; param[i++].Size = 18; param[i++].Size = 200; param[i++].Size = 18; param[i++].Size = 50; param[i++].Size = 30; param[i++].Size = 50; param[i++].Size = 30; return(param); }
public bool DeleteUserGroupByID(UserGroupInfo model, UserInfo user, ref string strError) { try { return(_db.DeleteUserGroupByID(model)); } catch (Exception ex) { strError = ex.Message; return(false); } }
public bool ExistsUserGroupNo(UserGroupInfo model, bool bIncludeDel, UserInfo user, ref string strError) { try { return(_db.ExistsUserGroupNo(model, bIncludeDel)); } catch (Exception ex) { strError = ex.Message; return(false); } }
private string GetFilterSql(UserGroupInfo model, UserInfo user) { try { string strSql = " Where ISNULL(IsDel,1) = 1 "; bool hadWhere = true; if (!string.IsNullOrEmpty(model.UserGroupNo)) { strSql = Common_Func.AddWhereAnd(strSql, hadWhere); strSql += " UserGroupNo Like '%" + model.UserGroupNo + "%' "; hadWhere = true; } if (!string.IsNullOrEmpty(model.UserGroupName)) { strSql = Common_Func.AddWhereAnd(strSql, hadWhere); strSql += " UserGroupName Like '%" + model.UserGroupName + "%' "; hadWhere = true; } if (!string.IsNullOrEmpty(model.Creater)) { strSql = Common_Func.AddWhereAnd(strSql, hadWhere); strSql += " Creater Like '%" + model.Creater + "%' "; hadWhere = true; } if (model.StartTime != null) { strSql = Common_Func.AddWhereAnd(strSql, hadWhere); strSql += " CreateTime >= " + model.StartTime.ToDateTime().Date.ToSqlTimeString() + " "; hadWhere = true; } if (model.EndTime != null) { strSql = Common_Func.AddWhereAnd(strSql, hadWhere); strSql += " CreateTime <= " + model.EndTime.ToDateTime().AddDays(1).Date.ToSqlTimeString() + " "; hadWhere = true; } return(strSql); } catch { return(string.Empty); } }
public bool SaveUserGroup(ref UserGroupInfo model) { SqlParameter[] param = GetParameterFromModel(model); OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_SaveUserGroup", param); string ErrorMsg = param[0].Value.ToDBString(); if (ErrorMsg.StartsWith("执行错误")) { throw new Exception(ErrorMsg); } else { model.ID = param[1].Value.ToInt32(); model.CreateTime = param[param.Length - 3].Value.ToDateTime(); model.ModifyTime = param[param.Length - 1].Value.ToDateTimeNull(); return(true); } }
public bool SaveUserGroup(ref UserGroupInfo model, UserInfo user, ref string strError) { try { if (model.ID <= 0) { model.Creater = user.UserNo; } else { model.Modifyer = user.UserNo; } return(_db.SaveUserGroup(ref model)); } catch (Exception ex) { strError = ex.Message; return(false); } }
public bool DeleteUserGroupByID(UserGroupInfo model) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000), new SqlParameter("@v_ID", model.ID.ToSqlValue()), }; param[0].Direction = ParameterDirection.Output; OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_DeleteUserGroupByID", param); string ErrorMsg = param[0].Value.ToDBString(); if (ErrorMsg.StartsWith("执行错误")) { throw new Exception(ErrorMsg); } else { return(true); } }
public bool ExistsUserGroupNo(UserGroupInfo model, bool bIncludeDel) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ErrorMsg", SqlDbType.NVarChar, 1000), new SqlParameter("@v_UserGroupNo", model.UserGroupNo.ToSqlValue()), new SqlParameter("@IncludeDel", bIncludeDel.ToSqlValue()), }; param[0].Direction = ParameterDirection.Output; OperationSql.ExecuteNonQuery2(CommandType.StoredProcedure, "Proc_ExistsUserGroupNo", param); string ErrorMsg = param[0].Value.ToDBString(); if (ErrorMsg.StartsWith("执行错误")) { throw new Exception(ErrorMsg); } else { return(string.IsNullOrEmpty(ErrorMsg)); } }