예제 #1
0
        private List <StockList> GenerateList(DataTable dt)
        {
            List <StockList> StockList = new List <Class.StockList>();

            foreach (DataRow DataRow in dt.Rows)
            {
                StockList Stock = new Class.StockList();
                Stock.ItemCode    = DataRow["ItemCode"].ToString();
                Stock.ItemName    = DataRow["ItemName"].ToString();
                Stock.Location    = DataRow["Location"].ToString();
                Stock.LocationID  = Convert.ToInt16(DataRow["LocationID"]);
                Stock.Measurement = DataRow["Measurement"].ToString();
                Stock.ProductID   = Convert.ToInt16(DataRow["ProductID"]);

                if (!DataRow.IsNull("Quantity"))
                {
                    Stock.Quantity = Convert.ToDecimal(DataRow["Quantity"]);
                }
                else
                {
                    Stock.Quantity = 0;
                }
                if (!DataRow.IsNull("Cost"))
                {
                    Stock.Cost = Convert.ToDecimal(DataRow["Cost"]);
                }
                else
                {
                    Stock.Cost = 0;
                }

                StockList.Add(Stock);
            }
            return(StockList);
        }
예제 #2
0
파일: Stock.xaml.cs 프로젝트: mercaditu/ERP
        private async void item_movementDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Class.StockList _item_movement = item_inventoryDataGrid.SelectedItem as Class.StockList;

            if (_item_movement != null)
            {
                int id_item_product = _item_movement.ProductID;

                int id_location = _item_movement.LocationID;
                using (db db = new db())
                {
                    item_movementViewSource        = ((CollectionViewSource)(FindResource("item_movementViewSource")));
                    item_movementViewSource.Source = await db.item_movement.Where(x => x.id_company == entity.CurrentSession.Id_Company &&
                                                                                  x.id_item_product == id_item_product &&
                                                                                  x.app_location.id_location == id_location &&
                                                                                  x.status == Status.Stock.InStock &&
                                                                                  x.trans_date <= InventoryDate
                                                                                  ).OrderByDescending(x => x.trans_date).ToListAsync();

                    foreach (item_movement item_movement in item_movementViewSource.View.Cast <item_movement>().ToList())
                    {
                        if (item_movement.item_movement_dimension.Count() > 0)
                        {
                            foreach (item_movement_dimension item_movement_dimension in item_movement.item_movement_dimension)
                            {
                                if (!(item_movement.comment.Contains(item_movement_dimension.app_dimension.name)))
                                {
                                    item_movement.comment += " " + item_movement_dimension.app_dimension.name + " : " + Math.Round(item_movement_dimension.value, 2) + ",";
                                }
                            }
                        }
                    }
                }
            }
        }