Ejemplo n.º 1
0
        private static Tab_UserLevel ToModel(DataRow row)
        {
            Tab_UserLevel model = new Tab_UserLevel();

            model.Idx           = row.IsNull("Idx")?null:(System.Int32?)row["Idx"];
            model.UserLevelName = row.IsNull("UserLevelName")?null:(System.String)row["UserLevelName"];
            model.SortNo        = row.IsNull("SortNo")?null:(System.Int32?)row["SortNo"];
            return(model);
        }
Ejemplo n.º 2
0
        public int AddNew(Tab_UserLevel model)
        {
            string sql = "insert into Tab_UserLevel(UserLevelName,SortNo)  values(@UserLevelName,@SortNo); select @@identity ;";
            int    Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql
                                                                 , new SqlParameter("@UserLevelName", model.UserLevelName)
                                                                 , new SqlParameter("@SortNo", model.SortNo)
                                                                 ));

            return(Idx);
        }
Ejemplo n.º 3
0
        public bool Update(Tab_UserLevel model)
        {
            string sql  = "update Tab_UserLevel set UserLevelName=@UserLevelName,SortNo=@SortNo where Idx=@Idx";
            int    rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql
                                                    , new SqlParameter("@UserLevelName", model.UserLevelName)
                                                    , new SqlParameter("@SortNo", model.SortNo)
                                                    , new SqlParameter("Idx", model.Idx)
                                                    );

            return(rows > 0);
        }
Ejemplo n.º 4
0
        public Tab_UserLevel Get(string Idx)
        {
            DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_UserLevel  where Idx=@Idx",
                                                    new SqlParameter("Idx", Idx)).Tables[0];

            if (dt.Rows.Count > 1)
            {
                throw new Exception("more than 1 row was found");
            }

            if (dt.Rows.Count <= 0)
            {
                return(null);
            }

            DataRow       row   = dt.Rows[0];
            Tab_UserLevel model = ToModel(row);

            return(model);
        }