Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hotel_app.Model.YH_user model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update YH_user set ");
            strSql.Append("yydh=@yydh,");
            strSql.Append("qymc=@qymc,");
            strSql.Append("yhbh=@yhbh,");
            strSql.Append("yhbm=@yhbm,");
            strSql.Append("yhxm=@yhxm,");
            strSql.Append("yhmm=@yhmm,");
            strSql.Append("R_lsbh=@R_lsbh,");
            strSql.Append("RoleName=@RoleName,");
            strSql.Append("is_top=@is_top,");
            strSql.Append("is_select=@is_select,");
            strSql.Append("zjm=@zjm");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yydh",      SqlDbType.VarChar,  50),
                new SqlParameter("@qymc",      SqlDbType.VarChar, 100),
                new SqlParameter("@yhbh",      SqlDbType.VarChar,  50),
                new SqlParameter("@yhbm",      SqlDbType.VarChar,  50),
                new SqlParameter("@yhxm",      SqlDbType.VarChar,  50),
                new SqlParameter("@yhmm",      SqlDbType.VarChar,  50),
                new SqlParameter("@R_lsbh",    SqlDbType.VarChar,  50),
                new SqlParameter("@RoleName",  SqlDbType.VarChar,  50),
                new SqlParameter("@is_top",    SqlDbType.Bit,       1),
                new SqlParameter("@is_select", SqlDbType.Bit,       1),
                new SqlParameter("@zjm",       SqlDbType.VarChar,  50),
                new SqlParameter("@ID",        SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.yydh;
            parameters[1].Value  = model.qymc;
            parameters[2].Value  = model.yhbh;
            parameters[3].Value  = model.yhbm;
            parameters[4].Value  = model.yhxm;
            parameters[5].Value  = model.yhmm;
            parameters[6].Value  = model.R_lsbh;
            parameters[7].Value  = model.RoleName;
            parameters[8].Value  = model.is_top;
            parameters[9].Value  = model.is_select;
            parameters[10].Value = model.zjm;
            parameters[11].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hotel_app.Model.YH_user model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into YH_user(");
            strSql.Append("yydh,qymc,yhbh,yhbm,yhxm,yhmm,R_lsbh,RoleName,is_top,is_select,zjm)");
            strSql.Append(" values (");
            strSql.Append("@yydh,@qymc,@yhbh,@yhbm,@yhxm,@yhmm,@R_lsbh,@RoleName,@is_top,@is_select,@zjm)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yydh",      SqlDbType.VarChar,  50),
                new SqlParameter("@qymc",      SqlDbType.VarChar, 100),
                new SqlParameter("@yhbh",      SqlDbType.VarChar,  50),
                new SqlParameter("@yhbm",      SqlDbType.VarChar,  50),
                new SqlParameter("@yhxm",      SqlDbType.VarChar,  50),
                new SqlParameter("@yhmm",      SqlDbType.VarChar,  50),
                new SqlParameter("@R_lsbh",    SqlDbType.VarChar,  50),
                new SqlParameter("@RoleName",  SqlDbType.VarChar,  50),
                new SqlParameter("@is_top",    SqlDbType.Bit,       1),
                new SqlParameter("@is_select", SqlDbType.Bit,       1),
                new SqlParameter("@zjm",       SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.yydh;
            parameters[1].Value  = model.qymc;
            parameters[2].Value  = model.yhbh;
            parameters[3].Value  = model.yhbm;
            parameters[4].Value  = model.yhxm;
            parameters[5].Value  = model.yhmm;
            parameters[6].Value  = model.R_lsbh;
            parameters[7].Value  = model.RoleName;
            parameters[8].Value  = model.is_top;
            parameters[9].Value  = model.is_select;
            parameters[10].Value = model.zjm;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hotel_app.Model.YH_user GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,yydh,qymc,yhbh,yhbm,yhxm,yhmm,R_lsbh,RoleName,is_top,is_select,zjm from YH_user ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Hotel_app.Model.YH_user model = new Hotel_app.Model.YH_user();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["yydh"] != null && ds.Tables[0].Rows[0]["yydh"].ToString() != "")
                {
                    model.yydh = ds.Tables[0].Rows[0]["yydh"].ToString();
                }
                if (ds.Tables[0].Rows[0]["qymc"] != null && ds.Tables[0].Rows[0]["qymc"].ToString() != "")
                {
                    model.qymc = ds.Tables[0].Rows[0]["qymc"].ToString();
                }
                if (ds.Tables[0].Rows[0]["yhbh"] != null && ds.Tables[0].Rows[0]["yhbh"].ToString() != "")
                {
                    model.yhbh = ds.Tables[0].Rows[0]["yhbh"].ToString();
                }
                if (ds.Tables[0].Rows[0]["yhbm"] != null && ds.Tables[0].Rows[0]["yhbm"].ToString() != "")
                {
                    model.yhbm = ds.Tables[0].Rows[0]["yhbm"].ToString();
                }
                if (ds.Tables[0].Rows[0]["yhxm"] != null && ds.Tables[0].Rows[0]["yhxm"].ToString() != "")
                {
                    model.yhxm = ds.Tables[0].Rows[0]["yhxm"].ToString();
                }
                if (ds.Tables[0].Rows[0]["yhmm"] != null && ds.Tables[0].Rows[0]["yhmm"].ToString() != "")
                {
                    model.yhmm = ds.Tables[0].Rows[0]["yhmm"].ToString();
                }
                if (ds.Tables[0].Rows[0]["R_lsbh"] != null && ds.Tables[0].Rows[0]["R_lsbh"].ToString() != "")
                {
                    model.R_lsbh = ds.Tables[0].Rows[0]["R_lsbh"].ToString();
                }
                if (ds.Tables[0].Rows[0]["RoleName"] != null && ds.Tables[0].Rows[0]["RoleName"].ToString() != "")
                {
                    model.RoleName = ds.Tables[0].Rows[0]["RoleName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["is_top"] != null && ds.Tables[0].Rows[0]["is_top"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["is_top"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_top"].ToString().ToLower() == "true"))
                    {
                        model.is_top = true;
                    }
                    else
                    {
                        model.is_top = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["is_select"] != null && ds.Tables[0].Rows[0]["is_select"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["is_select"].ToString() == "1") || (ds.Tables[0].Rows[0]["is_select"].ToString().ToLower() == "true"))
                    {
                        model.is_select = true;
                    }
                    else
                    {
                        model.is_select = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["zjm"] != null && ds.Tables[0].Rows[0]["zjm"].ToString() != "")
                {
                    model.zjm = ds.Tables[0].Rows[0]["zjm"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }