Example #1
0
        /// <summary>
        /// 获取符合条件的数据
        /// </summary>
        /// <param name="where">查询条件</param>
        /// <returns>符合条件的数据集</returns>
        public static List <Order> GetOrderByWhere(String where)
        {
            List <Order> orders = new List <Order>();

            String sql = String.Format("SELECT * FROM orders WHERE {0}", where);

            using (SQLiteDataReader reader = SQLiteHelper.ExecuteReader(SQLiteHelper.ConnectionStringLocalTransaction, System.Data.CommandType.Text, sql)){
                while (reader.Read())
                {
                    Order order = DataRowToModel(reader);
                    order.Details = OrderDetailDAL.GetDetailsByWhere("order_id = " + order.Id);
                    orders.Add(order);
                }
            }

            return(orders);
        }
Example #2
0
        public static bool DelToatlOut(SqlTransaction tr, string orderid)
        {
            bool state = true;
            IList <OrderDetailModel> orderdetails = OrderDetailDAL.GetOrderDetail(orderid);

            foreach (OrderDetailModel orderdetail in orderdetails)
            {
                string         sql   = "update LogicProductInventory set TotalOut=TotalOut-@count where ProductID=@productid";
                SqlParameter[] paras = new SqlParameter[2];
                paras[0] = new SqlParameter("@count", orderdetail.Quantity);
                paras[1] = new SqlParameter("@productid", orderdetail.ProductId);

                if (DBHelper.ExecuteNonQuery(tr, sql, paras, CommandType.Text) != 1)
                {
                    state = false;
                }
            }

            return(state);
        }