예제 #1
0
        private void FrmInventoryManagement_Load(object sender, EventArgs e)
        {
            db = new Session4Entities();
            var list = db.OrderItems.ToList <OrderItem>()
                       .Select(m => new
            {
                PartName        = m.Part.Name,
                TransactionType = m.Order.TransactionType.Name,
                Date            = m.Order.Date,
                Amount          = m.Amount,
                Source          = (db.Warehouses.Where(x => x.ID == m.Order.SourceWarehouseID).SingleOrDefault() != null) ? db.Warehouses.Where(x => x.ID == m.Order.SourceWarehouseID).SingleOrDefault().Name : "",
                Destination     = (db.Warehouses.Where(x => x.ID == m.Order.DestinationWarehouseID).SingleOrDefault() != null) ? db.Warehouses.Where(x => x.ID == m.Order.DestinationWarehouseID).SingleOrDefault().Name : "",
                ActionEdit      = "Edit",
                ActionRemove    = "Remove",
                OrderItemID     = m.ID,
                PartID          = m.PartID,
                OrderID         = m.OrderID
            }).OrderBy(m => m.Date).ThenBy(m => m.TransactionType).ToList();

            dataGridView.Rows.Clear();
            dataGridView.Columns[2].DefaultCellStyle.Format = "dd/MM/yyyy";
            foreach (var i in list)
            {
                dataGridView.Rows.Add(i.PartName, i.TransactionType, i.Date, i.Amount, i.Source, i.Destination, i.ActionEdit, i.ActionRemove, i.OrderItemID, i.PartID, i.OrderID);
                if (i.TransactionType == "Purchase Order")
                {
                    dataGridView.Rows[dataGridView.Rows.Count - 1].Cells["Amount"].Style.BackColor = Color.Green;
                }
            }
        }
예제 #2
0
        private void FrmBatchNumbers_Load(object sender, EventArgs e)
        {
            db     = new Session4Entities();
            row    = this.Tag as DataGridViewRow;
            partID = int.Parse(row.Cells["PartID"].Value.ToString());
            var list = db.OrderItems.Where(m => m.PartID == partID)
                       .Select(m => new {
                BatchNumber = m.BatchNumber
            }).Distinct().ToList();

            dataGridView.Rows.Clear();
            foreach (var r in list)
            {
                dataGridView.Rows.Add(r.BatchNumber);
            }
        }
예제 #3
0
        private void FrmPurchaseOrder_Load(object sender, EventArgs e)
        {
            db = new Session4Entities();

            cbSuppliers.DataSource    = db.Suppliers.ToList();
            cbSuppliers.DisplayMember = "Name";
            cbSuppliers.ValueMember   = "ID";

            cbWarehouse.DataSource    = db.Warehouses.ToList();
            cbWarehouse.DisplayMember = "Name";
            cbWarehouse.ValueMember   = "ID";

            cbPartName.DataSource    = db.Parts.ToList();
            cbPartName.DisplayMember = "Name";
            cbPartName.ValueMember   = "ID";

            if (isEdit)
            {
                row     = this.Tag as DataGridViewRow;
                orderID = int.Parse(row.Cells["OrderID"].Value.ToString());
                Order order = db.Orders.SingleOrDefault(m => m.ID == orderID);
                cbSuppliers.SelectedValue = order.SupplierID;
                if (order.SourceWarehouseID != null)
                {
                    cbWarehouse.SelectedValue = order.SourceWarehouseID;
                }
                date.Value = order.Date;

                var list = db.OrderItems.Where(m => m.Order.ID == orderID).Select(x => new
                {
                    PartName    = x.Part.Name,
                    BatchNumber = x.BatchNumber,
                    Amount      = x.Amount,
                    Action      = "Remove",
                    PartID      = x.PartID
                }).ToList();

                dataGridView.Rows.Clear();
                int index = 0;
                foreach (var i in list)
                {
                    dataGridView.Rows.Add(i.PartName, i.BatchNumber, i.Amount, i.Action, i.PartID);
                    dataGridView.Rows[index].DefaultCellStyle.BackColor = Color.Beige;
                    index++;
                }
            }
        }
예제 #4
0
        private void FrmInventoryReport_Load(object sender, EventArgs e)
        {
            db = new Session4Entities();
            cbWarehouse.DataSource    = db.Warehouses.ToList();
            cbWarehouse.DisplayMember = "Name";
            cbWarehouse.ValueMember   = "ID";

            long wareHouseID = long.Parse(cbWarehouse.SelectedValue.ToString());

            var list = db.Parts.ToList()
                       .Select(m => new {
                PartName      = m.Name,
                CurrentStock  = db.OrderItems.Where(i => i.PartID == m.ID).Count(),
                ReceivedStock = db.OrderItems.Where(i => i.PartID == m.ID && i.Order.DestinationWarehouseID == wareHouseID).Count(),
                Action        = (m.BatchNumberHasRequired == true) ? "View Batch Numbers" : "",
                PartID        = m.ID
            });

            dataGridView.Rows.Clear();
            foreach (var r in list)
            {
                dataGridView.Rows.Add(r.PartName, r.CurrentStock, r.ReceivedStock, r.Action, r.PartID);
            }
        }