Example #1
0
        /// <summary>
        /// 获取项目列表
        /// </summary>
        public List <Warehouse_Goods> GetGoods()
        {
            List <Warehouse_Goods> Goodss = null;
            string cmdText = "SELECT * FROM View_Warehouse_Goods";

            using (SqlDataReader reader = DBHelper.ExecuteReader(cmdText, CommandType.Text))
            {
                if (reader.HasRows)
                {
                    Goodss = new List <Warehouse_Goods>();
                    while (reader.Read())
                    {
                        Warehouse_Goods goods = new Warehouse_Goods()
                        {
                            GoodsID       = Convert.ToInt32(reader["GoodsID"]),
                            GoodsName     = reader["GoodsName"] as string,
                            Specification = reader["Specification"] as string,
                            Unit          = reader["Unit"] as string,
                            CategoryID    = Convert.ToInt32(reader["CategoryID"]),
                            CategoryName  = reader["CategoryName"] as string,
                            SupplierID    = Convert.ToInt32(reader["SupplierID"]),
                            SupplierName  = reader["SupplierName"] as string,
                            UnitPrice     = Convert.ToDouble(reader["UnitPrice"]),
                        };
                        Goodss.Add(goods);
                    }
                }
            }
            return(Goodss);
        }
Example #2
0
        protected void ListviewItemDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (lstGoods.SelectedItem == null)
            {
                return;
            }
            int             currentIndex = lstGoods.SelectedIndex;
            Warehouse_Goods goods        = lstGoods.SelectedItem as Warehouse_Goods;
            GoodsInfoWindow window       = new GoodsInfoWindow(goods);

            window.Owner = this;
            bool?result = window.ShowDialog().Value;

            if (result.HasValue && result == true)
            {
                Decorator    border       = VisualTreeHelper.GetChild(lstGoods, 0) as Decorator;
                ScrollViewer scrollViewer = null;
                double       theOffset    = 0;
                if (border != null)
                {
                    scrollViewer = border.Child as ScrollViewer;
                    if (scrollViewer != null)
                    {
                        theOffset = scrollViewer.VerticalOffset;
                    }
                }

                Window_Loaded(null, null);

                scrollViewer.ScrollToVerticalOffset(theOffset);
            }
        }
Example #3
0
 public GoodsInfoWindow(Warehouse_Goods goods)
 {
     InitializeComponent();
     btnAdd.Visibility  = Visibility.Collapsed;
     btnEdit.Visibility = Visibility.Visible;
     this.goods         = goods;
 }
Example #4
0
        /// <summary>
        /// 修改项目
        /// </summary>
        /// <param name="goods">需修改项目</param>
        public int UpdateGoods(Warehouse_Goods goods)
        {
            string cmdText = @"UPDATE [EasySystem].[dbo].[Warehouse_Goods]
   SET [GoodsName] = @GoodsName
      ,[Specification] = @Specification
      ,[Unit] = @Unit
      ,[CategoryID] = @CategoryID
      ,[SupplierID] = @SupplierID
      ,[UnitPrice] = @UnitPrice
 WHERE [GoodsID] = @GoodsID";

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@GoodsName", goods.GoodsName),
                new SqlParameter("@Specification", goods.Specification),
                new SqlParameter("@Unit", goods.Unit),
                new SqlParameter("@CategoryID", goods.CategoryID),
                new SqlParameter("@SupplierID", goods.SupplierID),
                new SqlParameter("@UnitPrice", goods.UnitPrice),
                new SqlParameter("@GoodsID", goods.GoodsID)
            };
            return(DBHelper.ExecuteNonQuery(cmdText, parameters, CommandType.Text));
        }
Example #5
0
        /// <summary>
        /// 新增项目
        /// </summary>
        /// <param name="goods">待新增项目</param>
        public int AddGoods(Warehouse_Goods goods)
        {
            int    result  = 0;
            string cmdText = @"PROC_AddGoods";

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@GoodsName", goods.GoodsName),
                new SqlParameter("@Specification", goods.Specification),
                new SqlParameter("@Unit", goods.Unit),
                new SqlParameter("@CategoryID", goods.CategoryID),
                new SqlParameter("@SupplierID", goods.SupplierID),
                new SqlParameter("@UnitPrice", goods.UnitPrice),
                new SqlParameter("@Result", DbType.Int32)
            };
            parameters[4].Direction = ParameterDirection.Output;
            DBHelper.ExecuteNonQuery(cmdText, parameters, CommandType.StoredProcedure);
            if (parameters[4].Value != null)
            {
                goods.GoodsID = Convert.ToInt32(parameters[4].Value);
                return(1);
            }
            return(-1);
        }