Example #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VAN_OA.Model.EFrom.A_Role_User GetModelGetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select   ");
            strSql.Append(" * ");
            strSql.Append(" from A_Role_User_View ");
            strSql.Append(" where ID=" + ID + " order by Role_User_Index,loginName ");


            VAN_OA.Model.EFrom.A_Role_User model = null;
            using (SqlConnection conn = DBHelp.getConn())
            {
                conn.Open();
                SqlCommand objCommand = new SqlCommand(strSql.ToString(), conn);
                using (SqlDataReader dataReader = objCommand.ExecuteReader())
                {
                    if (dataReader.Read())
                    {
                        model = ReaderBind(dataReader);
                    }
                }
            }
            return(model);
        }
Example #2
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public VAN_OA.Model.EFrom.A_Role_User ReaderBind(IDataReader dataReader)
        {
            VAN_OA.Model.EFrom.A_Role_User model = new VAN_OA.Model.EFrom.A_Role_User();
            object ojb;

            ojb = dataReader["iD"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ID = (int)ojb;
            }
            model.UserName     = dataReader["loginName"].ToString();
            model.RoleName     = dataReader["A_RoleName"].ToString();
            model.LoginName_ID = dataReader["LoginName_ID"].ToString();

            model.Role_User_Index = Convert.ToInt32(dataReader["Role_User_Index"]);
            model.RowState        = Convert.ToInt32(dataReader["RowState"]);
            try
            {
                model.UserId = Convert.ToInt32(dataReader["userId"].ToString());
            }
            catch (Exception)
            {
            }
            return(model);
        }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(VAN_OA.Model.EFrom.A_Role_User model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update A_Role_User set ");
            strSql.Append("A_RoleId=" + model.A_RoleId + ",");
            strSql.Append("User_Id=" + model.User_Id + ",");
            strSql.Append("Role_User_Index=" + model.Role_User_Index + ",");
            strSql.Append("RowState=" + model.RowState + "");
            strSql.Append(" where ID=" + model.ID + "");
            DBHelp.ExeCommand(strSql.ToString());
        }
Example #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VAN_OA.Model.EFrom.A_Role_User model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into A_Role_User(");
            strSql.Append("A_RoleId,User_Id,Role_User_Index,RowState");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("" + model.A_RoleId + ",");
            strSql.Append("" + model.User_Id + ",");
            strSql.Append("" + model.Role_User_Index + ",");
            strSql.Append("" + model.RowState + "");
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");

            int    result;
            object obj = DBHelp.ExeScalar(strSql.ToString());

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }