Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hotel_app.Model.YH_Applications model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update YH_Applications set ");
            strSql.Append("yydh=@yydh,");
            strSql.Append("qymc=@qymc,");
            strSql.Append("p_lsbh=@p_lsbh,");
            strSql.Append("A_Appdr=@A_Appdr,");
            strSql.Append("A_AppName=@A_AppName,");
            strSql.Append("is_top=@is_top,");
            strSql.Append("is_select=@is_select");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yydh",      SqlDbType.VarChar,  50),
                new SqlParameter("@qymc",      SqlDbType.VarChar, 100),
                new SqlParameter("@p_lsbh",    SqlDbType.VarChar,  50),
                new SqlParameter("@A_Appdr",   SqlDbType.VarChar,  50),
                new SqlParameter("@A_AppName", SqlDbType.VarChar,  50),
                new SqlParameter("@is_top",    SqlDbType.Bit,       1),
                new SqlParameter("@is_select", SqlDbType.Bit,       1),
                new SqlParameter("@ID",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.yydh;
            parameters[1].Value = model.qymc;
            parameters[2].Value = model.p_lsbh;
            parameters[3].Value = model.A_Appdr;
            parameters[4].Value = model.A_AppName;
            parameters[5].Value = model.is_top;
            parameters[6].Value = model.is_select;
            parameters[7].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public static List <Hotel_app.Model.YH_Applications> DataTableToList(DataTable dt)
        {
            List <Hotel_app.Model.YH_Applications> modelList = new List <Hotel_app.Model.YH_Applications>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Hotel_app.Model.YH_Applications model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Hotel_app.Model.YH_Applications();
                    if (dt.Rows[n]["A_Appdr"] != null && dt.Rows[n]["A_Appdr"].ToString() != "")
                    {
                        model.A_Appdr = dt.Rows[n]["A_Appdr"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hotel_app.Model.YH_Applications model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into YH_Applications(");
            strSql.Append("yydh,qymc,p_lsbh,A_Appdr,A_AppName,is_top,is_select)");
            strSql.Append(" values (");
            strSql.Append("@yydh,@qymc,@p_lsbh,@A_Appdr,@A_AppName,@is_top,@is_select)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@yydh",      SqlDbType.VarChar,  50),
                new SqlParameter("@qymc",      SqlDbType.VarChar, 100),
                new SqlParameter("@p_lsbh",    SqlDbType.VarChar,  50),
                new SqlParameter("@A_Appdr",   SqlDbType.VarChar,  50),
                new SqlParameter("@A_AppName", SqlDbType.VarChar,  50),
                new SqlParameter("@is_top",    SqlDbType.Bit,       1),
                new SqlParameter("@is_select", SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.yydh;
            parameters[1].Value = model.qymc;
            parameters[2].Value = model.p_lsbh;
            parameters[3].Value = model.A_Appdr;
            parameters[4].Value = model.A_AppName;
            parameters[5].Value = model.is_top;
            parameters[6].Value = model.is_select;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hotel_app.Model.YH_Applications GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,yydh,qymc,p_lsbh,A_Appdr,A_AppName,is_top,is_select from YH_Applications ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            Hotel_app.Model.YH_Applications model = new Hotel_app.Model.YH_Applications();
            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]["p_lsbh"] != null && ds.Tables[0].Rows[0]["p_lsbh"].ToString() != "")
                {
                    model.p_lsbh = ds.Tables[0].Rows[0]["p_lsbh"].ToString();
                }
                if (ds.Tables[0].Rows[0]["A_Appdr"] != null && ds.Tables[0].Rows[0]["A_Appdr"].ToString() != "")
                {
                    model.A_Appdr = ds.Tables[0].Rows[0]["A_Appdr"].ToString();
                }
                if (ds.Tables[0].Rows[0]["A_AppName"] != null && ds.Tables[0].Rows[0]["A_AppName"].ToString() != "")
                {
                    model.A_AppName = ds.Tables[0].Rows[0]["A_AppName"].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;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }