Пример #1
0
        private void Load_Existing_Orders()
        {
            int iIndex = 0;

            dgv_Orders_Initialize();
            DataAccessPOS dbPOS = new DataAccessPOS();

            orders = dbPOS.Get_Orders_by_Station(FrmSalesMain.strStation);
            if (orders.Count > 0)
            {
                ////////////////////////////////////////////////
                // Add the ordered item into datagrid view
                ////////////////////////////////////////////////
                isNewInvoice = true;
                iNewInvNo    = orders[0].InvoiceNo;
                foreach (var order in orders)
                {
                    iIndex++;
                    float iAmount = 0;
                    if (order.OrderCategoryId == 0)
                    {
                        iAmount = order.Quantity * order.OutUnitPrice;
                        this.dgv_Orders.Rows.Add(new String[] { order.ProductId.ToString(),
                                                                order.ProductName,
                                                                order.Quantity.ToString(),
                                                                order.OutUnitPrice.ToString("0.00"),
                                                                //iAmount.ToString("0.00")
                                                                order.Amount.ToString("0.00") });
                    }
                    else if (order.OrderCategoryId > 0) // Discount
                    {
                        iAmount = order.Amount;
                        this.dgv_Orders.Rows.Add(new String[] { order.ProductId.ToString(),
                                                                order.ProductName,
                                                                order.Quantity.ToString(),
                                                                order.Amount.ToString("0.00"),
                                                                //iAmount.ToString("0.00")
                                                                order.Amount.ToString("0.00") });
                    }
                    if (order.RFTagId > 0)
                    {
                        this.dgv_Orders.Rows[this.dgv_Orders.RowCount - 1].Tag = order.RFTagId;
                        DataGridViewRow row = this.dgv_Orders.Rows[this.dgv_Orders.RowCount - 1];
                        row.DefaultCellStyle.ForeColor = Color.Blue;
                    }
                    else
                    {
                        this.dgv_Orders.Rows[this.dgv_Orders.RowCount - 1].Tag = null;
                    }
                    this.dgv_Orders.FirstDisplayedScrollingRowIndex = dgv_Orders.RowCount - 1;
                    //this.dgv_Orders.FirstDisplayedScrollingRowIndex = Get_OrderedItem_Index_of_GridView(order.RFTagId);
                    //this.dgv_Orders.Rows[Get_OrderedItem_Index_of_GridView(order.RFTagId)].Selected = true;
                    // this.dgv_Orders.Rows[dgv_Orders.RowCount - 1].Selected = true;
                }
            }
            this.dgv_Orders.ClearSelection();
        }