コード例 #1
0
ファイル: DAL_T_SysUser.cs プロジェクト: rayworld/GTMIS
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public GTMIS.Model.T_SysUser GetModel(int FUserID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select FUserID, FUserName, FPassword, FRoleID, FDeptID, CreateBy, CreateDate  ");
            strSql.Append("  from T_SysUser ");
            strSql.Append(" where FUserID=@FUserID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FUserID", SqlDbType.Int, 4)
            };
            parameters[0].Value = FUserID;


            GTMIS.Model.T_SysUser model = new GTMIS.Model.T_SysUser();
            //DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            DataTable dt = SqlHelper.ExecuteDataTable(conn, strSql.ToString(), parameters);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["FUserID"].ToString() != "")
                {
                    model.FUserID = int.Parse(dt.Rows[0]["FUserID"].ToString());
                }
                model.FUserName = dt.Rows[0]["FUserName"].ToString();
                model.FPassword = dt.Rows[0]["FPassword"].ToString();
                if (dt.Rows[0]["FRoleID"].ToString() != "")
                {
                    model.FRoleID = int.Parse(dt.Rows[0]["FRoleID"].ToString());
                }
                if (dt.Rows[0]["FDeptID"].ToString() != "")
                {
                    model.FDeptID = int.Parse(dt.Rows[0]["FDeptID"].ToString());
                }
                model.CreateBy = dt.Rows[0]["CreateBy"].ToString();
                if (dt.Rows[0]["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(dt.Rows[0]["CreateDate"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: DAL_T_SysUser.cs プロジェクト: rayworld/GTMIS
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(GTMIS.Model.T_SysUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_SysUser set ");

            strSql.Append(" FUserName = @FUserName , ");
            strSql.Append(" FPassword = @FPassword , ");
            strSql.Append(" FRoleID = @FRoleID , ");
            strSql.Append(" FDeptID = @FDeptID , ");
            strSql.Append(" CreateBy = @CreateBy , ");
            strSql.Append(" CreateDate = @CreateDate  ");
            strSql.Append(" where FUserID=@FUserID ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@FUserID",    SqlDbType.Int,       4),
                new SqlParameter("@FUserName",  SqlDbType.NVarChar, 50),
                new SqlParameter("@FPassword",  SqlDbType.NVarChar, 50),
                new SqlParameter("@FRoleID",    SqlDbType.Int,       4),
                new SqlParameter("@FDeptID",    SqlDbType.Int,       4),
                new SqlParameter("@CreateBy",   SqlDbType.NVarChar, 50),
                new SqlParameter("@CreateDate", SqlDbType.DateTime)
            };

            parameters[0].Value = model.FUserID;
            parameters[1].Value = model.FUserName;
            parameters[2].Value = model.FPassword;
            parameters[3].Value = model.FRoleID;
            parameters[4].Value = model.FDeptID;
            parameters[5].Value = model.CreateBy;
            parameters[6].Value = model.CreateDate;
            //int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
            int rows = SqlHelper.ExecuteNonQuery(conn, strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: DAL_T_SysUser.cs プロジェクト: rayworld/GTMIS
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(GTMIS.Model.T_SysUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_SysUser(");
            strSql.Append("FUserName,FPassword,FRoleID,FDeptID,CreateBy,CreateDate");
            strSql.Append(") values (");
            strSql.Append("@FUserName,@FPassword,@FRoleID,@FDeptID,@CreateBy,@CreateDate");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FUserName",  SqlDbType.NVarChar, 50),
                new SqlParameter("@FPassword",  SqlDbType.NVarChar, 50),
                new SqlParameter("@FRoleID",    SqlDbType.Int,       4),
                new SqlParameter("@FDeptID",    SqlDbType.Int,       4),
                new SqlParameter("@CreateBy",   SqlDbType.NVarChar, 50),
                new SqlParameter("@CreateDate", SqlDbType.DateTime)
            };

            parameters[0].Value = model.FUserName;
            parameters[1].Value = model.FPassword;
            parameters[2].Value = model.FRoleID;
            parameters[3].Value = model.FDeptID;
            parameters[4].Value = model.CreateBy;
            parameters[5].Value = model.CreateDate;

            //object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
            object obj = SqlHelper.ExecuteScalar(conn, strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #4
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <GTMIS.Model.T_SysUser> DataTableToList(DataTable dt)
        {
            List <GTMIS.Model.T_SysUser> modelList = new List <GTMIS.Model.T_SysUser>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                GTMIS.Model.T_SysUser model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new GTMIS.Model.T_SysUser();
                    if (dt.Rows[n]["FUserID"].ToString() != "")
                    {
                        model.FUserID = int.Parse(dt.Rows[n]["FUserID"].ToString());
                    }
                    model.FUserName = dt.Rows[n]["FUserName"].ToString();
                    model.FPassword = dt.Rows[n]["FPassword"].ToString();
                    if (dt.Rows[n]["FRoleID"].ToString() != "")
                    {
                        model.FRoleID = int.Parse(dt.Rows[n]["FRoleID"].ToString());
                    }
                    if (dt.Rows[n]["FDeptID"].ToString() != "")
                    {
                        model.FDeptID = int.Parse(dt.Rows[n]["FDeptID"].ToString());
                    }
                    model.CreateBy = dt.Rows[n]["CreateBy"].ToString();
                    if (dt.Rows[n]["CreateDate"].ToString() != "")
                    {
                        model.CreateDate = DateTime.Parse(dt.Rows[n]["CreateDate"].ToString());
                    }


                    modelList.Add(model);
                }
            }
            return(modelList);
        }
コード例 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(GTMIS.Model.T_SysUser model)
 {
     return(dal.Update(model));
 }
コード例 #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(GTMIS.Model.T_SysUser model)
 {
     return(dal.Add(model));
 }