Esempio n. 1
0
        private void gridItems_CellLeave(object sender, ODGridClickEventArgs e)
        {
            int qtyOld = PIn.Int(_tableOrderItems.Rows[e.Row]["Qty"].ToString(), false);
            int qtyNew = 0;

            try {
                qtyNew = PIn.Int(gridItems.ListGridRows[e.Row].Cells[2].Text);              //0 if not valid input
            }
            catch { }
            double priceOld = PIn.Double(_tableOrderItems.Rows[e.Row]["Price"].ToString());
            double priceNew = PIn.Double(gridItems.ListGridRows[e.Row].Cells[3].Text);          //0 if not valid input

            //if(e.Col==2){//Qty
            //gridItems.ListGridRows[e.Row].Cells[2].Text=qtyNew.ToString();//Fix the cell formatting
            //if(qtyOld==qtyNew){
            //don't go to db.
            //gridItems.Invalidate();
            //return;
            //}
            //}
            //if(e.Col==3){//price
            //gridItems.ListGridRows[e.Row].Cells[3].Text=priceNew.ToString("n");//Fix the cell formatting
            //if(priceOld==priceNew){
            //don't go to db.
            //gridItems.Invalidate();
            //return;
            //}
            //}
            //gridItems.ListGridRows[e.Row].Cells[4].Text=(qtyNew*priceNew).ToString("n");
            //gridItems.Invalidate();
            if (qtyOld == qtyNew && priceOld == priceNew)
            {
                FillGridOrderItem(false);                //no refresh
            }
            else
            {
                SupplyOrderItem supplyOrderItem = SupplyOrderItems.SelectOne(PIn.Long(_tableOrderItems.Rows[e.Row]["SupplyOrderItemNum"].ToString()));
                supplyOrderItem.Qty   = qtyNew;
                supplyOrderItem.Price = priceNew;
                SupplyOrderItems.Update(supplyOrderItem);
                SupplyOrder updatedSupplyOrderItem = SupplyOrders.UpdateOrderPrice(supplyOrderItem.SupplyOrderNum);              //this might be an expensive query that we could avoid
                FillGridOrderItem();
                int index = _listSupplyOrders.FindIndex(x => x.SupplyOrderNum == supplyOrderItem.SupplyOrderNum);
                if (index < 0)               //Just in case, shouldn't happen
                {
                    FillGridOrders();
                    return;
                }
                _listSupplyOrders[index] = updatedSupplyOrderItem;
                gridOrders.SelectedGridRows[0].Cells[2].Text = updatedSupplyOrderItem.AmountTotal.ToString("c2");
                gridOrders.Invalidate();
            }
        }
Esempio n. 2
0
        private void gridOrderItem_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            FormSupplyOrderItemEdit formSupplyOrderItemEdit = new FormSupplyOrderItemEdit();

            formSupplyOrderItemEdit.SupplyOrderItemCur = SupplyOrderItems.SelectOne(PIn.Long(_tableOrderItems.Rows[e.Row]["SupplyOrderItemNum"].ToString()));
            formSupplyOrderItemEdit.ListSuppliersAll   = Suppliers.GetAll();
            formSupplyOrderItemEdit.ShowDialog();
            if (formSupplyOrderItemEdit.DialogResult != DialogResult.OK)
            {
                return;
            }
            //SupplyOrderItems.Update(formSupplyOrderItemEdit.SupplyOrderItemCur);
            UpdatePriceAndRefresh();
        }