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

            strSql.Append("update " + databaseprefix + "openarea set ");
            strSql.Append("provinces=@provinces,");
            strSql.Append("city=@city");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",        SqlDbType.Int,       4),
                new SqlParameter("@provinces", SqlDbType.VarChar, 100),
                new SqlParameter("@city",      SqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.provinces;
            parameters[2].Value = model.city;

            try
            {
                int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                if (rows > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.openarea model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "openarea(");
            strSql.Append("provinces,city)");
            strSql.Append(" values (");
            strSql.Append("@provinces,@city)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@provinces",   SqlDbType.VarChar, 100),
                new SqlParameter("@city",        SqlDbType.VarChar, 100),
                new SqlParameter("@ReturnValue", SqlDbType.Int)
            };
            parameters[0].Value     = model.provinces;
            parameters[1].Value     = model.city;
            parameters[2].Direction = ParameterDirection.Output;

            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql.ToString(), parameters);

            sqllist.Add(cmd);

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return((int)parameters[2].Value);
        }
Exemplo n.º 3
0
        /*#region 绑定类别=================================
         * private void TreeBind(int _channel_id)
         * {
         *  BLL.article_category bll = new BLL.article_category();
         *  DataTable dt = bll.GetList(0, _channel_id);
         *
         *  this.ddlCategoryId.Items.Clear();
         *  this.ddlCategoryId.Items.Add(new ListItem("请选择类别...", ""));
         *  foreach (DataRow dr in dt.Rows)
         *  {
         *      string Id = dr["id"].ToString();
         *      int ClassLayer = int.Parse(dr["class_layer"].ToString());
         *      string Title = dr["title"].ToString().Trim();
         *
         *      if (ClassLayer == 1)
         *      {
         *          this.ddlCategoryId.Items.Add(new ListItem(Title, Id));
         *      }
         *      else
         *      {
         *          Title = "├ " + Title;
         *          Title = Vincent._DTcms.Utils.StringOfChar(ClassLayer - 1, " ") + Title;
         *          this.ddlCategoryId.Items.Add(new ListItem(Title, Id));
         *      }
         *  }
         * }
         #endregion*/

        #region 赋值操作=================================
        private void ShowInfo(int _id)
        {
            BLL.openarea   bll   = new BLL.openarea();
            Model.openarea model = bll.GetModel(_id);

            provinces.Value  = model.provinces;
            provinces1.Value = model.provinces;
            city.Value       = model.city;
            city1.Value      = model.city;
        }
Exemplo n.º 4
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            Model.openarea model = new Model.openarea();
            BLL.openarea   bll   = new BLL.openarea();
            if (this.provinces1.Value == "所在省份")
            {
                JscriptMsg("请选择省份!", "", "Error");
                return(result);
            }
            else if (this.provinces1.Value == "北京市")
            {
                model.provinces = this.provinces1.Value;
                model.city      = this.provinces1.Value;
            }
            else if (this.provinces1.Value == "天津市")
            {
                model.provinces = this.provinces1.Value;
                model.city      = this.provinces1.Value;
            }
            else if (this.provinces1.Value == "上海市")
            {
                model.provinces = this.provinces1.Value;
                model.city      = this.provinces1.Value;
            }
            else if (this.provinces1.Value == "重庆市")
            {
                model.provinces = this.provinces1.Value;
                model.city      = this.provinces1.Value;
            }
            else
            {
                model.provinces = this.provinces1.Value;
                model.city      = this.city1.Value;
            }

            model.id = _id;



            if (bll.Update(model))
            {
                //开始生成缩略图咯

                //AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Add.ToString(), "添加" + this.channel_name + "频道内容:" + model.title); //记录日志
                result = true;
            }
            return(result);
        }
Exemplo n.º 5
0
        protected string CombSqlTxt(int _outlet_id, int _city_id, string _keywords)
        {
            StringBuilder strTemp = new StringBuilder();

            if (_city_id > 0)
            {
                BLL.openarea   open  = new BLL.openarea();
                Model.openarea openm = open.GetModel(_city_id);
                if (openm != null)
                {
                    BLL.outlet outlet = new BLL.outlet();
                    DataTable  dt     = outlet.GetList(0, " city='" + openm.city + "'", " id").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        StringBuilder st = new StringBuilder();
                        string        ss = string.Empty;
                        st.Append("(");
                        foreach (DataRow item in dt.Rows)
                        {
                            st.Append(item["id"] + ",");
                        }
                        if (st.ToString().Trim() != "(")
                        {
                            ss = DelLastComma(st.ToString().Trim());
                            st.Append(")");
                        }
                        strTemp.Append(" and store_id in" + ss + ")");
                    }
                    else
                    {
                        strTemp.Append(" and store_id in(null)");
                    }
                }
            }

            if (_outlet_id > 0)
            {
                strTemp.Append(" and store_id=" + _outlet_id);
            }

            _keywords = _keywords.Replace("'", "");
            if (!string.IsNullOrEmpty(_keywords))
            {
                strTemp.Append(" and (user_name='" + _keywords + "' or remark like '%" + _keywords + "%')");
            }

            return(strTemp.ToString());
        }
Exemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.openarea GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,provinces,city from " + databaseprefix + "openarea ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.openarea model = new Model.openarea();
            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]["provinces"] != null && ds.Tables[0].Rows[0]["provinces"].ToString() != "")
                {
                    model.provinces = ds.Tables[0].Rows[0]["provinces"].ToString();
                }
                if (ds.Tables[0].Rows[0]["city"] != null && ds.Tables[0].Rows[0]["city"].ToString() != "")
                {
                    model.city = ds.Tables[0].Rows[0]["city"].ToString();
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.openarea model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.openarea model)
 {
     return(dal.Add(model));
 }
Exemplo n.º 9
0
        /// <summary>
        /// 获取订单总金额
        /// </summary>
        /// <param name="total_amount"></param>
        protected void getTotalAmount()
        {
            total_amount  = 0M;
            coupon_amount = 0M;
            refund_amount = 0M;
            if (datetime == null)
            {
                BLL.orders bll = new BLL.orders();
                DataTable  dt;
                if (this.outlet_id > 0)
                {
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99 and store_id=" + this.outlet_id, " add_time desc,id desc").Tables[0];
                }
                else if (this.city_id > 0)
                {
                    BLL.openarea   open    = new BLL.openarea();
                    Model.openarea openm   = open.GetModel(this.city_id);
                    StringBuilder  strTemp = new StringBuilder();
                    if (openm != null)
                    {
                        BLL.outlet outlet = new BLL.outlet();
                        DataTable  dts    = outlet.GetList(0, " city='" + openm.city + "'", " id").Tables[0];
                        if (dts.Rows.Count > 0)
                        {
                            StringBuilder st = new StringBuilder();
                            string        ss = string.Empty;
                            st.Append("(");
                            foreach (DataRow item in dts.Rows)
                            {
                                st.Append(item["id"] + ",");
                            }
                            if (st.ToString().Trim() != "(")
                            {
                                ss = DelLastComma(st.ToString().Trim());
                                st.Append(")");
                            }
                            strTemp.Append(" and store_id in" + ss + ")");
                        }
                        else
                        {
                            strTemp.Append(" and store_id in(null)");
                        }
                    }
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99" + strTemp, " add_time desc,id desc").Tables[0];
                }
                else
                {
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99", " add_time desc,id desc").Tables[0];
                }
                foreach (DataRow row in dt.Rows)
                {
                    total_amount += decimal.Parse(row["order_amount"].ToString());
                    if (row["refund_status"].ToString() != "" && int.Parse(row["refund_status"].ToString()) == 3) //统计退款
                    {
                        refund_amount += decimal.Parse(row["order_amount"].ToString());
                    }
                    BLL.user_coupon_log couponbll = new BLL.user_coupon_log();//统计优惠券
                    if (row["str_code"].ToString() != "")
                    {
                        Model.user_coupon_log couponmodel = couponbll.GetModel(row["str_code"].ToString());
                        if (couponmodel != null && couponmodel.status == 2)
                        {
                            BLL.user_coupon   copbl = new BLL.user_coupon();
                            Model.user_coupon copmo = copbl.GetModel(couponmodel.coupon_id);
                            if (copmo != null)
                            {
                                if (copmo.amount > decimal.Parse(row["order_amount"].ToString()))
                                {
                                    coupon_amount += decimal.Parse(row["order_amount"].ToString());
                                }
                                else
                                {
                                    coupon_amount += copmo.amount;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                BLL.orders bll = new BLL.orders();

                DataTable dt;
                if (this.outlet_id > 0)
                {
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99 and store_id=" + this.outlet_id, " add_time desc,id desc").Tables[0];
                }
                else
                {
                    dt = bll.GetOrderAmount(0, " status!=1 and status!=99", " add_time desc,id desc").Tables[0];
                }

                //DataTable dt = bll.GetOrderAmount(0, " status!=1 and status!=99 and datediff(dd,add_time,'" + datetime + "')=0", " add_time desc,id desc").Tables[0];
                foreach (DataRow row in dt.Rows)
                {
                    total_amount += decimal.Parse(row["order_amount"].ToString());
                    if (row["refund_status"].ToString() != "" && int.Parse(row["refund_status"].ToString()) == 3)
                    {
                        refund_amount += decimal.Parse(row["order_amount"].ToString());
                    }
                    BLL.user_coupon_log couponbll = new BLL.user_coupon_log();//统计优惠券
                    if (row["str_code"].ToString() != "")
                    {
                        Model.user_coupon_log couponmodel = couponbll.GetModel(row["str_code"].ToString());
                        if (couponmodel != null && couponmodel.status == 2)
                        {
                            BLL.user_coupon   copbl = new BLL.user_coupon();
                            Model.user_coupon copmo = copbl.GetModel(couponmodel.coupon_id);
                            if (copmo != null)
                            {
                                if (copmo.amount > decimal.Parse(row["order_amount"].ToString()))
                                {
                                    coupon_amount += decimal.Parse(row["order_amount"].ToString());
                                }
                                else
                                {
                                    coupon_amount += copmo.amount;
                                }
                            }
                        }
                    }
                }
            }
        }