Example #1
0
        private void FillGridOrderItem(bool refresh = true)
        {
            long orderNum = 0;

            if (gridOrders.GetSelectedIndex() != -1)           //an order is selected
            {
                orderNum = _listSupplyOrders[gridOrders.GetSelectedIndex()].SupplyOrderNum;
            }
            if (refresh)
            {
                _tableOrderItems = SupplyOrderItems.GetItemsForOrder(orderNum);
            }
            gridItems.BeginUpdate();
            gridItems.ListGridColumns.Clear();
            GridColumn col = new GridColumn(Lan.g(this, "Catalog #"), 80);

            gridItems.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Description"), 320);
            gridItems.ListGridColumns.Add(col);
            col            = new GridColumn(Lan.g(this, "Qty"), 60, HorizontalAlignment.Center);
            col.IsEditable = true;
            gridItems.ListGridColumns.Add(col);
            col            = new GridColumn(Lan.g(this, "Price/Unit"), 70, HorizontalAlignment.Right);
            col.IsEditable = true;
            gridItems.ListGridColumns.Add(col);
            col = new GridColumn(Lan.g(this, "Subtotal"), 70, HorizontalAlignment.Right);
            gridItems.ListGridColumns.Add(col);
            gridItems.ListGridRows.Clear();
            GridRow row;
            double  price;
            int     qty;
            double  subtotal;

            for (int i = 0; i < _tableOrderItems.Rows.Count; i++)
            {
                row = new GridRow();
                row.Cells.Add(_tableOrderItems.Rows[i]["CatalogNumber"].ToString());
                row.Cells.Add(_tableOrderItems.Rows[i]["Descript"].ToString());
                qty = PIn.Int(_tableOrderItems.Rows[i]["Qty"].ToString());
                row.Cells.Add(qty.ToString());
                price = PIn.Double(_tableOrderItems.Rows[i]["Price"].ToString());
                row.Cells.Add(price.ToString("n"));
                subtotal = ((double)qty) * price;
                row.Cells.Add(subtotal.ToString("n"));
                gridItems.ListGridRows.Add(row);
            }
            gridItems.EndUpdate();
        }
Example #2
0
        private void FillGridOrderItem()
        {
            long orderNum = 0;

            if (gridOrders.GetSelectedIndex() != -1)           //an order is selected
            {
                orderNum = _listOrders[gridOrders.GetSelectedIndex()].SupplyOrderNum;
            }
            _tableOrderItems = SupplyOrderItems.GetItemsForOrder(orderNum);
            gridItems.BeginUpdate();
            gridItems.Columns.Clear();
            //ODGridColumn col=new ODGridColumn(Lan.g(this,"Supplier"),120);
            //gridItems.Columns.Add(col);
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Catalog #"), 80);

            gridItems.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Description"), 320);
            gridItems.Columns.Add(col);
            col            = new ODGridColumn(Lan.g(this, "Qty"), 60, HorizontalAlignment.Center);
            col.IsEditable = true;
            gridItems.Columns.Add(col);
            col            = new ODGridColumn(Lan.g(this, "Price/Unit"), 70, HorizontalAlignment.Right);
            col.IsEditable = true;
            gridItems.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Subtotal"), 70, HorizontalAlignment.Right);
            gridItems.Columns.Add(col);
            gridItems.Rows.Clear();
            ODGridRow row;
            double    price;
            int       qty;
            double    subtotal;
            double    total         = 0;
            bool      autocalcTotal = true;

            for (int i = 0; i < _tableOrderItems.Rows.Count; i++)
            {
                row = new ODGridRow();
                //if(gridOrders.GetSelectedIndex()==-1){
                //	row.Cells.Add("");
                //}
                //else{
                //	row.Cells.Add(Suppliers.GetName(ListSuppliers,ListOrders[gridOrders.GetSelectedIndex()].SupplierNum));
                //}
                row.Cells.Add(_tableOrderItems.Rows[i]["CatalogNumber"].ToString());
                row.Cells.Add(_tableOrderItems.Rows[i]["Descript"].ToString());
                qty = PIn.Int(_tableOrderItems.Rows[i]["Qty"].ToString());
                row.Cells.Add(qty.ToString());
                price = PIn.Double(_tableOrderItems.Rows[i]["Price"].ToString());
                row.Cells.Add(price.ToString("n"));
                subtotal = ((double)qty) * price;
                row.Cells.Add(subtotal.ToString("n"));
                gridItems.Rows.Add(row);
                if (subtotal == 0)
                {
                    autocalcTotal = false;
                }
                total += subtotal;
            }
            gridItems.EndUpdate();
            if (gridOrders.GetSelectedIndex() != -1 &&
                autocalcTotal &&
                total != _listOrders[gridOrders.GetSelectedIndex()].AmountTotal)
            {
                SupplyOrder order = _listOrders[gridOrders.GetSelectedIndex()].Copy();
                order.AmountTotal = total;
                SupplyOrders.Update(order);
                FillGridOrders();
                for (int i = 0; i < _listOrders.Count; i++)
                {
                    if (_listOrders[i].SupplyOrderNum == order.SupplyOrderNum)
                    {
                        gridOrders.SetSelected(i, true);
                    }
                }
            }
        }