Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WeiXinPF.Model.wx_diancai_shopinfo DataRowToModel(DataRow row)
        {
            WeiXinPF.Model.wx_diancai_shopinfo model = new WeiXinPF.Model.wx_diancai_shopinfo();
            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["wid"] != null && row["wid"].ToString() != "")
                {
                    model.wid = int.Parse(row["wid"].ToString());
                }
                if (row["hotelName"] != null)
                {
                    model.hotelName = row["hotelName"].ToString();
                }
                if (row["hotelLogo"] != null)
                {
                    model.hotelLogo = row["hotelLogo"].ToString();
                }
                if (row["limiteOrder"] != null && row["limiteOrder"].ToString() != "")
                {
                    if ((row["limiteOrder"].ToString() == "1") || (row["limiteOrder"].ToString().ToLower() == "true"))
                    {
                        model.limiteOrder = true;
                    }
                    else
                    {
                        model.limiteOrder = false;
                    }
                }
                if (row["dcRename"] != null)
                {
                    model.dcRename = row["dcRename"].ToString();
                }
                if (row["sendPrice"] != null && row["sendPrice"].ToString() != "")
                {
                    model.sendPrice = decimal.Parse(row["sendPrice"].ToString());
                }
                if (row["sendCost"] != null && row["sendCost"].ToString() != "")
                {
                    model.sendCost = decimal.Parse(row["sendCost"].ToString());
                }
                if (row["freeSendcost"] != null && row["freeSendcost"].ToString() != "")
                {
                    model.freeSendcost = int.Parse(row["freeSendcost"].ToString());
                }
                if (row["radius"] != null)
                {
                    model.radius = row["radius"].ToString();
                }
                if (row["sendArea"] != null)
                {
                    model.sendArea = row["sendArea"].ToString();
                }
                if (row["tel"] != null)
                {
                    model.tel = row["tel"].ToString();
                }
                if (row["address"] != null)
                {
                    model.address = row["address"].ToString();
                }
                if (row["personLimite"] != null && row["personLimite"].ToString() != "")
                {
                    model.personLimite = int.Parse(row["personLimite"].ToString());
                }
                if (row["notice"] != null)
                {
                    model.notice = row["notice"].ToString();
                }
                if (row["hotelintroduction"] != null)
                {
                    model.hotelintroduction = row["hotelintroduction"].ToString();
                }
                if (row["email"] != null)
                {
                    model.email = row["email"].ToString();
                }
                if (row["emailpwd"] != null)
                {
                    model.emailpwd = row["emailpwd"].ToString();
                }
                if (row["stmp"] != null)
                {
                    model.stmp = row["stmp"].ToString();
                }
                if (row["css"] != null)
                {
                    model.css = row["css"].ToString();
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.createDate = DateTime.Parse(row["createDate"].ToString());
                }
                if (row["kcType"] != null)
                {
                    model.kcType = row["kcType"].ToString();
                }
                if (row["miaoshu"] != null)
                {
                    model.miaoshu = row["miaoshu"].ToString();
                }
                if (row["xplace"] != null && row["xplace"].ToString() != "")
                {
                    model.xplace = decimal.Parse(row["xplace"].ToString());
                }
                if (row["yplace"] != null && row["yplace"].ToString() != "")
                {
                    model.yplace = decimal.Parse(row["yplace"].ToString());
                }

                model.hoteltimeBegin  = ToDateTime(row["hoteltimeBegin"]);
                model.hoteltimeEnd    = ToDateTime(row["hoteltimeEnd"]);
                model.hoteltimeBegin1 = ToDateTime(row["hoteltimeBegin1"]);
                model.hoteltimeEnd1   = ToDateTime(row["hoteltimeEnd1"]);
                model.hoteltimeBegin2 = ToDateTime(row["hoteltimeBegin2"]);
                model.hoteltimeEnd2   = ToDateTime(row["hoteltimeEnd2"]);

                if (row["hoteltimeEnd2"] != null && row["hoteltimeEnd2"].ToString() != "")
                {
                    model.hoteltimeEnd2 = DateTime.Parse(row["hoteltimeEnd2"].ToString());
                }

                if (row["Operator"] != null && row["Operator"].ToString() != "")
                {
                    model.Operator = row["Operator"].ToString();
                }

                if (row["Recommend"] != null && row["Recommend"].ToString() != "")
                {
                    model.Recommend = row.Field <bool>("Recommend");
                }

                if (row["Mobile"] != null && row["Mobile"].ToString() != "")
                {
                    model.Mobile = row["Mobile"].ToString();
                }
            }
            return(model);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WeiXinPF.Model.wx_diancai_shopinfo model)
        {
            StringBuilder query = new StringBuilder();

            query.Append("insert into wx_diancai_shopinfo(");
            query.Append("wid,hotelName,hotelLogo,hoteltimeBegin,hoteltimeEnd,limiteOrder,dcRename,sendPrice,sendCost,freeSendcost,radius,sendArea,tel,address,personLimite,notice,hotelintroduction,email,emailpwd,stmp,css,createDate,kcType,miaoshu,xplace,yplace,hoteltimeBegin1,hoteltimeEnd1,hoteltimeBegin2,hoteltimeEnd2,Operator,Recommend,Mobile)");
            query.Append(" values (");
            query.Append("@wid,@hotelName,@hotelLogo,@hoteltimeBegin,@hoteltimeEnd,@limiteOrder,@dcRename,@sendPrice,@sendCost,@freeSendcost,@radius,@sendArea,@tel,@address,@personLimite,@notice,@hotelintroduction,@email,@emailpwd,@stmp,@css,@createDate,@kcType,@miaoshu,@xplace,@yplace,@hoteltimeBegin1,@hoteltimeEnd1,@hoteltimeBegin2,@hoteltimeEnd2,@Operator,@Recommend,@Mobile)");
            query.Append("Select @Id=Scope_Identity();");
            query.Append("Update dbo.wx_diancai_shopinfo Set ShopCode=Right('0000'+Cast(@Id As Varchar(10)),4) Where Id=@Id");

            using (IDbConnection db = DbFactory.GetOpenedConnection())
            {
                DynamicParameters dynamicParameters = new DynamicParameters();
                dynamicParameters.AddDynamicParams(model);
                dynamicParameters.Add("@Id", dbType: DbType.Int32, direction: ParameterDirection.Output);

                db.Execute(query.ToString(), dynamicParameters);

                return(dynamicParameters.Get <int>("@Id"));
            }
            //SqlParameter[] parameters = {
            //        new SqlParameter("@wid", SqlDbType.Int,4),
            //        new SqlParameter("@hotelName", SqlDbType.VarChar,500),
            //        new SqlParameter("@hotelLogo", SqlDbType.VarChar,200),
            //        new SqlParameter("@hoteltimeBegin", SqlDbType.DateTime),
            //        new SqlParameter("@hoteltimeEnd", SqlDbType.DateTime),
            //        new SqlParameter("@limiteOrder", SqlDbType.Bit,1),
            //        new SqlParameter("@dcRename", SqlDbType.VarChar,200),
            //        new SqlParameter("@sendPrice", SqlDbType.Float,8),
            //        new SqlParameter("@sendCost", SqlDbType.Float,8),
            //        new SqlParameter("@freeSendcost", SqlDbType.Int,4),
            //        new SqlParameter("@radius", SqlDbType.VarChar,200),
            //        new SqlParameter("@sendArea", SqlDbType.VarChar,200),
            //        new SqlParameter("@tel", SqlDbType.VarChar,100),
            //        new SqlParameter("@address", SqlDbType.VarChar,200),
            //        new SqlParameter("@personLimite", SqlDbType.Int,4),
            //        new SqlParameter("@notice", SqlDbType.VarChar,2000),
            //        new SqlParameter("@hotelintroduction", SqlDbType.VarChar,2000),
            //        new SqlParameter("@email", SqlDbType.VarChar,200),
            //        new SqlParameter("@emailpwd", SqlDbType.VarChar,100),
            //        new SqlParameter("@stmp", SqlDbType.VarChar,100),
            //        new SqlParameter("@css", SqlDbType.VarChar,200),
            //        new SqlParameter("@createDate", SqlDbType.DateTime),
            //        new SqlParameter("@kcType", SqlDbType.VarChar,4000),
            //        new SqlParameter("@miaoshu", SqlDbType.VarChar,200),
            //        new SqlParameter("@xplace", SqlDbType.Float,8),
            //        new SqlParameter("@yplace", SqlDbType.Float,8),
            //        new SqlParameter("@hoteltimeBegin1", SqlDbType.DateTime),
            //        new SqlParameter("@hoteltimeEnd1", SqlDbType.DateTime),
            //        new SqlParameter("@hoteltimeBegin2", SqlDbType.DateTime),
            //        new SqlParameter("@hoteltimeEnd2", SqlDbType.DateTime),
            //        new SqlParameter("@Operator", SqlDbType.VarChar),
            //        new SqlParameter("@Recommend", SqlDbType.Bit),
            //        new SqlParameter("@Mobile",SqlDbType.VarChar)
            //};
            //parameters[0].Value = model.wid;
            //parameters[1].Value = model.hotelName;
            //parameters[2].Value = model.hotelLogo;
            //parameters[3].Value = model.hoteltimeBegin;
            //parameters[4].Value = model.hoteltimeEnd;
            //parameters[5].Value = model.limiteOrder;
            //parameters[6].Value = model.dcRename;
            //parameters[7].Value = model.sendPrice;
            //parameters[8].Value = model.sendCost;
            //parameters[9].Value = model.freeSendcost;
            //parameters[10].Value = model.radius;
            //parameters[11].Value = model.sendArea;
            //parameters[12].Value = model.tel;
            //parameters[13].Value = model.address;
            //parameters[14].Value = model.personLimite;
            //parameters[15].Value = model.notice;
            //parameters[16].Value = model.hotelintroduction;
            //parameters[17].Value = model.email;
            //parameters[18].Value = model.emailpwd;
            //parameters[19].Value = model.stmp;
            //parameters[20].Value = model.css;
            //parameters[21].Value = model.createDate;
            //parameters[22].Value = model.kcType;
            //parameters[23].Value = model.miaoshu;
            //parameters[24].Value = model.xplace;
            //parameters[25].Value = model.yplace;
            //parameters[26].Value = model.hoteltimeBegin1;
            //parameters[27].Value = model.hoteltimeEnd1;
            //parameters[28].Value = model.hoteltimeBegin2;
            //parameters[29].Value = model.hoteltimeEnd2;
            //parameters[30].Value = model.Operator;
            //parameters[31].Value = model.Recommend;
            //parameters[32].Value = model.Mobile;

            //object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            //if (obj == null)
            //{
            //    return 0;
            //}
            //else
            //{
            //    return Convert.ToInt32(obj);
            //}
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WeiXinPF.Model.wx_diancai_shopinfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_diancai_shopinfo set ");
            strSql.Append("wid=@wid,");
            strSql.Append("hotelName=@hotelName,");
            strSql.Append("hotelLogo=@hotelLogo,");
            strSql.Append("hoteltimeBegin=@hoteltimeBegin,");
            strSql.Append("hoteltimeEnd=@hoteltimeEnd,");
            strSql.Append("limiteOrder=@limiteOrder,");
            strSql.Append("dcRename=@dcRename,");
            strSql.Append("sendPrice=@sendPrice,");
            strSql.Append("sendCost=@sendCost,");
            strSql.Append("freeSendcost=@freeSendcost,");
            strSql.Append("radius=@radius,");
            strSql.Append("sendArea=@sendArea,");
            strSql.Append("tel=@tel,");
            strSql.Append("address=@address,");
            strSql.Append("personLimite=@personLimite,");
            strSql.Append("notice=@notice,");
            strSql.Append("hotelintroduction=@hotelintroduction,");
            strSql.Append("email=@email,");
            strSql.Append("emailpwd=@emailpwd,");
            strSql.Append("stmp=@stmp,");
            strSql.Append("css=@css,");
            //strSql.Append("createDate=@createDate,");
            strSql.Append("kcType=@kcType,");
            strSql.Append("miaoshu=@miaoshu,");
            strSql.Append("xplace=@xplace,");
            strSql.Append("yplace=@yplace,");
            strSql.Append("hoteltimeBegin1=@hoteltimeBegin1,");
            strSql.Append("hoteltimeEnd1=@hoteltimeEnd1,");
            strSql.Append("hoteltimeBegin2=@hoteltimeBegin2,");
            strSql.Append("hoteltimeEnd2=@hoteltimeEnd2,");
            strSql.Append("Operator=@Operator,");
            strSql.Append("Recommend=@Recommend,");
            strSql.Append("Mobile=@Mobile");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@wid",               SqlDbType.Int,          4),
                new SqlParameter("@hotelName",         SqlDbType.VarChar,    500),
                new SqlParameter("@hotelLogo",         SqlDbType.VarChar,    200),
                new SqlParameter("@hoteltimeBegin",    SqlDbType.DateTime),
                new SqlParameter("@hoteltimeEnd",      SqlDbType.DateTime),
                new SqlParameter("@limiteOrder",       SqlDbType.Bit,          1),
                new SqlParameter("@dcRename",          SqlDbType.VarChar,    200),
                new SqlParameter("@sendPrice",         SqlDbType.Float,        8),
                new SqlParameter("@sendCost",          SqlDbType.Float,        8),
                new SqlParameter("@freeSendcost",      SqlDbType.Int,          4),
                new SqlParameter("@radius",            SqlDbType.VarChar,    200),
                new SqlParameter("@sendArea",          SqlDbType.VarChar,    200),
                new SqlParameter("@tel",               SqlDbType.VarChar,    100),
                new SqlParameter("@address",           SqlDbType.VarChar,    200),
                new SqlParameter("@personLimite",      SqlDbType.Int,          4),
                new SqlParameter("@notice",            SqlDbType.VarChar,   2000),
                new SqlParameter("@hotelintroduction", SqlDbType.VarChar,   2000),
                new SqlParameter("@email",             SqlDbType.VarChar,    200),
                new SqlParameter("@emailpwd",          SqlDbType.VarChar,    100),
                new SqlParameter("@stmp",              SqlDbType.VarChar,    100),
                new SqlParameter("@css",               SqlDbType.VarChar,    200),
                //new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@kcType",            SqlDbType.VarChar,   4000),
                new SqlParameter("@miaoshu",           SqlDbType.VarChar,    200),
                new SqlParameter("@xplace",            SqlDbType.Float,        8),
                new SqlParameter("@yplace",            SqlDbType.Float,        8),
                new SqlParameter("@hoteltimeBegin1",   SqlDbType.DateTime),
                new SqlParameter("@hoteltimeEnd1",     SqlDbType.DateTime),
                new SqlParameter("@hoteltimeBegin2",   SqlDbType.DateTime),
                new SqlParameter("@hoteltimeEnd2",     SqlDbType.DateTime),
                new SqlParameter("@Operator",          SqlDbType.VarChar),
                new SqlParameter("@Recommend",         SqlDbType.Bit),
                new SqlParameter("@Mobile",            SqlDbType.VarChar),
                new SqlParameter("@id",                SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.wid;
            parameters[1].Value  = model.hotelName;
            parameters[2].Value  = model.hotelLogo;
            parameters[3].Value  = model.hoteltimeBegin;
            parameters[4].Value  = model.hoteltimeEnd;
            parameters[5].Value  = model.limiteOrder;
            parameters[6].Value  = model.dcRename;
            parameters[7].Value  = model.sendPrice;
            parameters[8].Value  = model.sendCost;
            parameters[9].Value  = model.freeSendcost;
            parameters[10].Value = model.radius;
            parameters[11].Value = model.sendArea;
            parameters[12].Value = model.tel;
            parameters[13].Value = model.address;
            parameters[14].Value = model.personLimite;
            parameters[15].Value = model.notice;
            parameters[16].Value = model.hotelintroduction;
            parameters[17].Value = model.email;
            parameters[18].Value = model.emailpwd;
            parameters[19].Value = model.stmp;
            parameters[20].Value = model.css;
            //parameters[21].Value = model.createDate;
            parameters[21].Value = model.kcType;
            parameters[22].Value = model.miaoshu;
            parameters[23].Value = model.xplace;
            parameters[24].Value = model.yplace;
            parameters[25].Value = model.hoteltimeBegin1;
            parameters[26].Value = model.hoteltimeEnd1;
            parameters[27].Value = model.hoteltimeBegin2;
            parameters[28].Value = model.hoteltimeEnd2;
            parameters[29].Value = model.Operator;
            parameters[30].Value = model.Recommend;
            parameters[31].Value = model.Mobile;
            parameters[32].Value = model.id;

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

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