/// <summary>
            /// 对象实体绑定数据
            /// </summary>
            public Lebi_Transport_Container ReaderBind(IDataReader dataReader)
            {
                Lebi_Transport_Container model = new Lebi_Transport_Container();
                object ojb;

                ojb = dataReader["id"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.id = (int)ojb;
                }
                model.Name        = dataReader["Name"].ToString();
                model.Description = dataReader["Description"].ToString();
                ojb = dataReader["Volume"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Volume = (decimal)ojb;
                }
                ojb = dataReader["Weight"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Weight = (decimal)ojb;
                }
                ojb = dataReader["Sort"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.Sort = (int)ojb;
                }
                return(model);
            }
            /// <summary>
            /// 更新一条数据
            /// </summary>
            public void Update(Lebi_Transport_Container model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("update [Lebi_Transport_Container] set ");
                strSql.Append("Name= @Name,");
                strSql.Append("Description= @Description,");
                strSql.Append("Volume= @Volume,");
                strSql.Append("Weight= @Weight,");
                strSql.Append("Sort= @Sort");
                strSql.Append(" where id=@id");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id",          SqlDbType.Int,        4),
                    new SqlParameter("@Name",        SqlDbType.NVarChar, 100),
                    new SqlParameter("@Description", SqlDbType.NVarChar, 255),
                    new SqlParameter("@Volume",      SqlDbType.Decimal,    9),
                    new SqlParameter("@Weight",      SqlDbType.Decimal,    9),
                    new SqlParameter("@Sort",        SqlDbType.Int, 4)
                };
                parameters[0].Value = model.id;
                parameters[1].Value = model.Name;
                parameters[2].Value = model.Description;
                parameters[3].Value = model.Volume;
                parameters[4].Value = model.Weight;
                parameters[5].Value = model.Sort;

                SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters);
            }
            /// <summary>
            /// 增加一条数据
            /// </summary>
            public int Add(Lebi_Transport_Container model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("insert into [Lebi_Transport_Container](");
                strSql.Append("Name,Description,Volume,Weight,Sort)");
                strSql.Append(" values (");
                strSql.Append("@Name,@Description,@Volume,@Weight,@Sort)");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Name",        model.Name),
                    new SqlParameter("@Description", model.Description),
                    new SqlParameter("@Volume",      model.Volume),
                    new SqlParameter("@Weight",      model.Weight),
                    new SqlParameter("@Sort",        model.Sort)
                };

                object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters);

                if (obj == null)
                {
                    return(1);
                }
                else
                {
                    return(Convert.ToInt32(obj));
                }
            }
            /// <summary>
            /// 得到一个对象实体 by id
            /// </summary>
            public Lebi_Transport_Container GetModel(int id)
            {
                StringBuilder strSql = new StringBuilder();

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

                Lebi_Transport_Container model = new Lebi_Transport_Container();
                DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                    {
                        model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                    }
                    model.Name        = ds.Tables[0].Rows[0]["Name"].ToString();
                    model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                    if (ds.Tables[0].Rows[0]["Volume"].ToString() != "")
                    {
                        model.Volume = decimal.Parse(ds.Tables[0].Rows[0]["Volume"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["Weight"].ToString() != "")
                    {
                        model.Weight = decimal.Parse(ds.Tables[0].Rows[0]["Weight"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                    {
                        model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                    }
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
            /// <summary>
            /// 增加一条数据
            /// </summary>
            public int Add(Lebi_Transport_Container model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("insert into [Lebi_Transport_Container](");
                strSql.Append("[Name],[Description],[Volume],[Weight],[Sort])");
                strSql.Append(" values (");
                strSql.Append("@Name,@Description,@Volume,@Weight,@Sort)");
                OleDbParameter[] parameters =
                {
                    new OleDbParameter("@Name",        model.Name),
                    new OleDbParameter("@Description", model.Description),
                    new OleDbParameter("@Volume",      model.Volume),
                    new OleDbParameter("@Weight",      model.Weight),
                    new OleDbParameter("@Sort",        model.Sort)
                };

                AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters);
                return(1);
            }
            /// <summary>
            /// 得到一个对象实体 by where条件
            /// </summary>
            public Lebi_Transport_Container GetModel(string strWhere)
            {
                if (strWhere.IndexOf("lbsql{") > 0)
                {
                    SQLPara para = new SQLPara(strWhere, "", "");
                    return(GetModel(para));
                }
                StringBuilder strSql = new StringBuilder();

                strSql.Append("select  top 1  * from [Lebi_Transport_Container] ");
                strSql.Append(" where " + strWhere + "");
                Lebi_Transport_Container model = new Lebi_Transport_Container();
                DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString());

                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                    {
                        model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                    }
                    model.Name        = ds.Tables[0].Rows[0]["Name"].ToString();
                    model.Description = ds.Tables[0].Rows[0]["Description"].ToString();
                    if (ds.Tables[0].Rows[0]["Volume"].ToString() != "")
                    {
                        model.Volume = decimal.Parse(ds.Tables[0].Rows[0]["Volume"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["Weight"].ToString() != "")
                    {
                        model.Weight = decimal.Parse(ds.Tables[0].Rows[0]["Weight"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["Sort"].ToString() != "")
                    {
                        model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString());
                    }
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
            /// <summary>
            /// 更新一条数据
            /// </summary>
            public void Update(Lebi_Transport_Container model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("update [Lebi_Transport_Container] set ");
                strSql.Append("[Name]=@Name,");
                strSql.Append("[Description]=@Description,");
                strSql.Append("[Volume]=@Volume,");
                strSql.Append("[Weight]=@Weight,");
                strSql.Append("[Sort]=@Sort");
                strSql.Append(" where id=" + model.id);
                OleDbParameter[] parameters =
                {
                    new OleDbParameter("@Name",        model.Name),
                    new OleDbParameter("@Description", model.Description),
                    new OleDbParameter("@Volume",      model.Volume),
                    new OleDbParameter("@Weight",      model.Weight),
                    new OleDbParameter("@Sort",        model.Sort)
                };

                AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters);
            }
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = RequestTool.RequestInt("id", 0);

            if (id == 0)
            {
                if (!EX_Admin.Power("transport_add", "添加配送方式"))
                {
                    WindowNoPower();
                }
            }
            else
            {
                if (!EX_Admin.Power("transport_edit", "编辑配送方式"))
                {
                    WindowNoPower();
                }
            }
            model = B_Lebi_Transport_Container.GetModel(id);
            if (model == null)
            {
                model = new Lebi_Transport_Container();
            }
        }
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_Transport_Container SafeBindForm(Lebi_Transport_Container model)
 {
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = Shop.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Description"] != null)
     {
         model.Description = Shop.Tools.RequestTool.RequestSafeString("Description");
     }
     if (HttpContext.Current.Request["Volume"] != null)
     {
         model.Volume = Shop.Tools.RequestTool.RequestDecimal("Volume", 0);
     }
     if (HttpContext.Current.Request["Weight"] != null)
     {
         model.Weight = Shop.Tools.RequestTool.RequestDecimal("Weight", 0);
     }
     if (HttpContext.Current.Request["Sort"] != null)
     {
         model.Sort = Shop.Tools.RequestTool.RequestInt("Sort", 0);
     }
     return(model);
 }
예제 #10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_Transport_Container model)
 {
     D_Lebi_Transport_Container.Instance.Update(model);
 }
예제 #11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_Transport_Container model)
 {
     return(D_Lebi_Transport_Container.Instance.Add(model));
 }
예제 #12
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_Transport_Container SafeBindForm(Lebi_Transport_Container model)
 {
     return(D_Lebi_Transport_Container.Instance.SafeBindForm(model));
 }
예제 #13
0
파일: EX_Area.cs 프로젝트: yzbjack/LebiShop
        /// <summary>
        /// 获得运费备注
        /// </summary>
        /// <param name="weight"></param>
        /// <param name="volume"></param>
        /// <param name="price"></param>
        /// <param name="ordermoney"></param>
        /// <returns></returns>
        public static string GerYunFeiMark(decimal weight, decimal volume, Lebi_Transport_Price price, decimal ordermoney = 0)
        {
            string res = "";

            if (price.IsOnePrice == 1 && ordermoney >= price.OrderMoney)//满足订单金额要求
            {
                return("");
            }
            else
            {
                Lebi_Transport transport = B_Lebi_Transport.GetModel(price.Transport_id);
                decimal        money     = price.Price;
                if (transport.Type_id_TransportType == 331)
                {
                    //货柜方式计算
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    List <KeyValue>      kvs = jss.Deserialize <List <KeyValue> >(price.Container);
                    string ids = "";
                    foreach (KeyValue kv in kvs)
                    {
                        if (ids == "")
                        {
                            ids = kv.K;
                        }
                        else
                        {
                            ids += "," + kv.K;
                        }
                    }
                    int     count  = 0; //需要的货柜数量
                    decimal cprice = 0; //使用的货柜价格
                    if (ids != "")
                    {
                        List <Lebi_Transport_Container> conts = B_Lebi_Transport_Container.GetList("id in (lbsql{" + ids + "})", "Volume desc");
                        //判断使用哪个货柜
                        Lebi_Transport_Container UseCont = new Lebi_Transport_Container();
                        foreach (Lebi_Transport_Container cont in conts)
                        {
                            if (volume / 100 / 100 / 100 > cont.Volume)
                            {
                                UseCont = cont;
                                break;
                            }
                        }
                        if (UseCont.id == 0)
                        {
                            UseCont = conts.FirstOrDefault();
                        }
                        UseCont.Weight = UseCont.Weight * 1000 * 1000;     //单位转换为克
                        UseCont.Volume = UseCont.Volume * 100 * 100 * 100; //单位转换为立方厘米
                        KeyValue kv = (from m in kvs
                                       where m.K == UseCont.id.ToString()
                                       select m).ToList().FirstOrDefault();
                        cprice = Convert.ToDecimal(kv.V);
                        if (weight > UseCont.Weight)
                        {
                            //按重量计算
                            count = (int)(weight / UseCont.Weight);
                            if (weight % UseCont.Weight > 0)
                            {
                                count++;
                            }
                        }
                        else
                        {
                            //按体积计算
                            count = (int)(volume / UseCont.Volume);
                            if (volume % UseCont.Volume > 0)
                            {
                                count++;
                            }
                        }
                        count = count == 0 ? 1 : count;
                        res   = UseCont.Name + ":" + count;
                    }
                }
                else
                {
                }
            }
            return(res);
        }
예제 #14
0
파일: EX_Area.cs 프로젝트: yzbjack/LebiShop
        /// <summary>
        /// 计算运费
        /// </summary>
        /// <param name="weight"></param>
        /// <param name="volume"></param>
        /// <param name="price"></param>
        /// <param name="ordermoney"></param>
        /// <returns></returns>
        public static decimal GetYunFei(decimal weight, decimal volume, Lebi_Transport_Price price, decimal ordermoney)
        {
            if (price == null)
            {
                price = new Lebi_Transport_Price();
            }
            decimal res = 0;

            if (ordermoney >= price.OrderMoney && price.OrderMoney > 0)//满足订单金额要求
            {
                return(price.Price_OrderMoneyOK);
            }
            if (price.IsOnePrice == 1)//定额运费
            {
                return(price.Price);
            }
            else
            {
                Lebi_Transport transport = B_Lebi_Transport.GetModel(price.Transport_id);
                if (transport == null)
                {
                    return(0);
                }
                decimal money = price.Price;
                if (transport.Type_id_TransportType == 331)
                {
                    //货柜方式计算
                    JavaScriptSerializer jss = new JavaScriptSerializer();
                    List <KeyValue>      kvs = jss.Deserialize <List <KeyValue> >(price.Container);
                    string ids = "";
                    foreach (KeyValue kv in kvs)
                    {
                        if (ids == "")
                        {
                            ids = kv.K;
                        }
                        else
                        {
                            ids += "," + kv.K;
                        }
                    }
                    int     count  = 0; //需要的货柜数量
                    decimal cprice = 0; //使用的货柜价格
                    if (ids != "")
                    {
                        List <Lebi_Transport_Container> conts = B_Lebi_Transport_Container.GetList("id in (lbsql{" + ids + "})", "Volume desc");
                        //判断使用哪个货柜
                        Lebi_Transport_Container UseCont = new Lebi_Transport_Container();
                        foreach (Lebi_Transport_Container cont in conts)
                        {
                            if (volume / 100 / 100 / 100 > cont.Volume)
                            {
                                UseCont = cont;
                                break;
                            }
                        }
                        if (UseCont.id == 0)
                        {
                            UseCont = conts.FirstOrDefault();
                        }
                        UseCont.Weight = UseCont.Weight * 1000 * 1000;     //单位转换为克
                        UseCont.Volume = UseCont.Volume * 100 * 100 * 100; //单位转换为立方厘米
                        KeyValue kv = (from m in kvs
                                       where m.K == UseCont.id.ToString()
                                       select m).ToList().FirstOrDefault();
                        cprice = Convert.ToDecimal(kv.V);
                        if (weight > UseCont.Weight)
                        {
                            //按重量计算
                            count = (int)(weight / UseCont.Weight);
                            if (weight % UseCont.Weight > 0)
                            {
                                count++;
                            }
                        }
                        else
                        {
                            //按体积计算
                            count = (int)(volume / UseCont.Volume);
                            if (volume % UseCont.Volume > 0)
                            {
                                count++;
                            }
                        }
                    }
                    count = count == 0 ? 1 : count;
                    money = money + cprice * count;
                }
                else
                { //包裹方式计算
                    int wei = (int)weight + 1;
                    if (weight > price.Weight_Start)
                    {
                        try
                        {
                            decimal step = (weight - price.Weight_Start) / price.Weight_Step;
                            step  = Math.Ceiling(step);
                            money = money + step * price.Price_Step;
                        }
                        catch (DivideByZeroException)
                        {
                            // money = money;
                        }
                    }
                }

                res = money;
            }
            return(res);
        }