示例#1
0
        ///<summary>Save changes to orderItems based on input in grid.</summary>
        //private bool saveChangesHelper() {
        //	if(gridItems.Rows.Count==0) {
        //		return true;
        //	}
        //	//validate ------------------------------------------------------------------------
        //	for(int i=0;i<gridItems.Rows.Count;i++) {
        //		int qtyThisRow=0;
        //		double priceThisRow=0;
        //		if(gridItems.Rows[i].Cells[2].Text!=""){
        //			try{
        //					qtyThisRow=Int32.Parse(gridItems.Rows[i].Cells[2].Text);
        //			}
        //			catch{
        //				MsgBox.Show(this,"Please fix errors in Qty column first.");
        //				return false;
        //			}
        //		}
        //		if(gridItems.Rows[i].Cells[3].Text!=""){
        //			try{
        //					priceThisRow=double.Parse(gridItems.Rows[i].Cells[3].Text);
        //			}
        //			catch{
        //				MsgBox.Show(this,"Please fix errors in Price column first.");
        //				return false;
        //			}
        //		}
        //	}
        //	//Save changes---------------------------------------------------------------------------
        //	//List<SupplyOrderItem> listOrderItems=OpenDentBusiness.Crud.SupplyOrderItemCrud.TableToList(tableOrderItems);//turn table into list of supplyOrderItem objects
        //	for(int i=0;i<gridItems.Rows.Count;i++) {
        //		int qtyThisRow=PIn.Int(gridItems.Rows[i].Cells[2].Text);//already validated
        //		double priceThisRow=PIn.Double(gridItems.Rows[i].Cells[3].Text);//already validated
        //		if(qtyThisRow==PIn.Int(tableOrderItems.Rows[i]["Qty"].ToString())
        //			&& priceThisRow==PIn.Double(tableOrderItems.Rows[i]["Price"].ToString()))
        //		{
        //			continue;//no changes to order item.
        //		}
        //		SupplyOrderItem soi=new SupplyOrderItem();
        //		soi.SupplyNum=PIn.Long(tableOrderItems.Rows[i]["SupplyNum"].ToString());
        //		soi.SupplyOrderItemNum=PIn.Long(tableOrderItems.Rows[i]["SupplyOrderItemNum"].ToString());
        //		soi.SupplyOrderNum=ListOrders[gridOrders.GetSelectedIndex()].SupplyOrderNum;
        //		soi.Qty=qtyThisRow;
        //		soi.Price=priceThisRow;
        //		SupplyOrderItems.Update(soi);
        //	}//end gridItems
        //	SupplyOrders.UpdateOrderPrice(ListOrders[gridOrders.GetSelectedIndex()].SupplyOrderNum);
        //	int selectedIndex=gridOrders.GetSelectedIndex();
        //	ListOrdersAll = SupplyOrders.GetAll();//update new totals
        //	FillGridOrders();
        //	if(selectedIndex!=-1) {
        //		gridOrders.SetSelected(selectedIndex,true);
        //	}
        //	return true;
        //}

        private void gridItems_CellLeave(object sender, ODGridClickEventArgs e)
        {
            //no need to check which cell was edited, just reprocess both cells
            int qtyNew = 0;          //default value.

            try {
                qtyNew = PIn.Int(gridItems.Rows[e.Row].Cells[2].Text);              //0 if not valid input
            }
            catch { }
            double          priceNew = PIn.Double(gridItems.Rows[e.Row].Cells[3].Text); //0 if not valid input
            SupplyOrderItem suppOI   = SupplyOrderItems.CreateObject(PIn.Long(_tableOrderItems.Rows[e.Row]["SupplyOrderItemNum"].ToString()));

            suppOI.Qty   = qtyNew;
            suppOI.Price = priceNew;
            SupplyOrderItems.Update(suppOI);
            SupplyOrders.UpdateOrderPrice(suppOI.SupplyOrderNum);
            gridItems.Rows[e.Row].Cells[2].Text = qtyNew.ToString();                 //to standardize formatting.  They probably didn't type .00
            gridItems.Rows[e.Row].Cells[3].Text = priceNew.ToString("n");            //to standardize formatting.  They probably didn't type .00
            gridItems.Rows[e.Row].Cells[4].Text = (qtyNew * priceNew).ToString("n"); //to standardize formatting.  They probably didn't type .00
            gridItems.Invalidate();
            int si = gridOrders.GetSelectedIndex();

            _listOrdersAll = SupplyOrders.GetAll();
            FillGridOrders();
            gridOrders.SetSelected(si, true);
        }
示例#2
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();
            }
        }
示例#3
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textQty.errorProvider1.GetError(textQty) != "" ||
         textPrice.errorProvider1.GetError(textPrice) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     ItemCur.Qty   = PIn.Int(textQty.Text);
     ItemCur.Price = PIn.Double(textPrice.Text);
     SupplyOrderItems.Update(ItemCur);            //never new
     DialogResult = DialogResult.OK;
 }
示例#4
0
        private void gridOrderItem_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            FormSupplyOrderItemEdit FormSOIE = new FormSupplyOrderItemEdit();

            FormSOIE.ItemCur      = SupplyOrderItems.CreateObject(PIn.Long(_tableOrderItems.Rows[e.Row]["SupplyOrderItemNum"].ToString()));
            FormSOIE.ListSupplier = Suppliers.GetAll();
            FormSOIE.ShowDialog();
            if (FormSOIE.DialogResult != DialogResult.OK)
            {
                return;
            }
            SupplyOrderItems.Update(FormSOIE.ItemCur);
            UpdatePriceAndRefresh();
        }
示例#5
0
        private void gridOrderItem_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            FormSupplyOrderItemEdit FormSOIE = new FormSupplyOrderItemEdit();

            FormSOIE.ItemCur      = SupplyOrderItems.CreateObject((long)tableOrderItems.Rows[e.Row]["SupplyOrderItemNum"]);
            FormSOIE.ListSupplier = Suppliers.CreateObjects();
            FormSOIE.ShowDialog();
            if (FormSOIE.DialogResult != DialogResult.OK)
            {
                return;
            }
            SupplyOrderItems.Update(FormSOIE.ItemCur);
            ListOrdersAll = SupplyOrders.GetAll();            //force refresh because total might have changed.
            int gridSelect = gridOrders.SelectedIndices[0];

            FillGridOrders();
            gridOrders.SetSelected(gridSelect, true);
            FillGridOrderItem();
        }