Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Hotel_app.Model.View_Xxfmx_zb model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into View_Xxfmx_zb(");
            strSql.Append("mxbh,zb_sl,zb_sj,zb_jjje,zb_Total_cb)");
            strSql.Append(" values (");
            strSql.Append("@mxbh,@zb_sl,@zb_sj,@zb_jjje,@zb_Total_cb)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@mxbh",        SqlDbType.VarChar,   50),
                new SqlParameter("@zb_sl",       SqlDbType.Decimal,    9),
                new SqlParameter("@zb_sj",       SqlDbType.DateTime),
                new SqlParameter("@zb_jjje",     SqlDbType.Decimal,    9),
                new SqlParameter("@zb_Total_cb", SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.mxbh;
            parameters[1].Value = model.zb_sl;
            parameters[2].Value = model.zb_sj;
            parameters[3].Value = model.zb_jjje;
            parameters[4].Value = model.zb_Total_cb;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Hotel_app.Model.View_Xxfmx_zb GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 mxbh,zb_sl,zb_sj,zb_jjje,zb_Total_cb from View_Xxfmx_zb ");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
            };

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["mxbh"] != null && ds.Tables[0].Rows[0]["mxbh"].ToString() != "")
                {
                    model.mxbh = ds.Tables[0].Rows[0]["mxbh"].ToString();
                }
                if (ds.Tables[0].Rows[0]["zb_sl"] != null && ds.Tables[0].Rows[0]["zb_sl"].ToString() != "")
                {
                    model.zb_sl = decimal.Parse(ds.Tables[0].Rows[0]["zb_sl"].ToString());
                }
                if (ds.Tables[0].Rows[0]["zb_sj"] != null && ds.Tables[0].Rows[0]["zb_sj"].ToString() != "")
                {
                    model.zb_sj = DateTime.Parse(ds.Tables[0].Rows[0]["zb_sj"].ToString());
                }
                if (ds.Tables[0].Rows[0]["zb_jjje"] != null && ds.Tables[0].Rows[0]["zb_jjje"].ToString() != "")
                {
                    model.zb_jjje = decimal.Parse(ds.Tables[0].Rows[0]["zb_jjje"].ToString());
                }
                if (ds.Tables[0].Rows[0]["zb_Total_cb"] != null && ds.Tables[0].Rows[0]["zb_Total_cb"].ToString() != "")
                {
                    model.zb_Total_cb = decimal.Parse(ds.Tables[0].Rows[0]["zb_Total_cb"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hotel_app.Model.View_Xxfmx_zb model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update View_Xxfmx_zb set ");
            strSql.Append("mxbh=@mxbh,");
            strSql.Append("zb_sl=@zb_sl,");
            strSql.Append("zb_sj=@zb_sj,");
            strSql.Append("zb_jjje=@zb_jjje,");
            strSql.Append("zb_Total_cb=@zb_Total_cb");
            strSql.Append(" where ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@mxbh",        SqlDbType.VarChar,   50),
                new SqlParameter("@zb_sl",       SqlDbType.Decimal,    9),
                new SqlParameter("@zb_sj",       SqlDbType.DateTime),
                new SqlParameter("@zb_jjje",     SqlDbType.Decimal,    9),
                new SqlParameter("@zb_Total_cb", SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.mxbh;
            parameters[1].Value = model.zb_sl;
            parameters[2].Value = model.zb_sj;
            parameters[3].Value = model.zb_jjje;
            parameters[4].Value = model.zb_Total_cb;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }