Esempio n. 1
0
 /// <summary>Creates a new order with all the items currently highlighted as a new pending order.</summary>
 private void butCreateOrders_Click(object sender,EventArgs e)
 {
     //Not visible in IsSelectMode
     if(gridMain.SelectedIndices.Length==0){
         MsgBox.Show(this,"Please select supplies, first.");
         return;
     }
     //they are not ordered by supplier, so we need to keep track of a local list of orders
     List<SupplyOrder> listSupplyOrders=new List<SupplyOrder>();
     SupplyOrder supplyOrder=null;
     for(int i=0;i<gridMain.SelectedIndices.Length;i++){
         supplyOrder=listSupplyOrders.FirstOrDefault(x=>x.SupplierNum==_listSupplies[gridMain.SelectedIndices[i]].SupplierNum);
         if(supplyOrder==null){
             supplyOrder=new SupplyOrder();
             supplyOrder.SupplierNum=_listSupplies[gridMain.SelectedIndices[i]].SupplierNum;
             supplyOrder.IsNew=true;
             supplyOrder.DatePlaced=new DateTime(2500,1,1); //date used for new 'pending' orders.
             supplyOrder.Note="";
             supplyOrder.UserNum=Security.CurUser.UserNum;
             supplyOrder.SupplyOrderNum=SupplyOrders.Insert(supplyOrder);
             listSupplyOrders.Add(supplyOrder);
         }
         SupplyOrderItem supplyOrderItem=new SupplyOrderItem();
         supplyOrderItem.SupplyNum=_listSupplies[gridMain.SelectedIndices[i]].SupplyNum;
         supplyOrderItem.Qty=_listSupplies[gridMain.SelectedIndices[i]].OrderQty;
         supplyOrderItem.Price=_listSupplies[gridMain.SelectedIndices[i]].Price;
         supplyOrderItem.SupplyOrderNum=supplyOrder.SupplyOrderNum;
         SupplyOrderItems.Insert(supplyOrderItem);
     }
     for(int i=0;i<listSupplyOrders.Count;i++){
         SupplyOrders.UpdateOrderPrice(listSupplyOrders[i].SupplyOrderNum);
     }
     MessageBox.Show(Lan.g(this,"Done. Added ")+listSupplyOrders.Count.ToString()+Lan.g(this," orders.  Manage orders from Orders window"));
     DialogResult=DialogResult.OK;
 }
Esempio n. 2
0
        private void butNewOrder_Click(object sender, EventArgs e)
        {
            if (listSupplier.Count == 0)
            {
                MsgBox.Show(this, "Please add suppliers first.  Use the menu at the top of this window.");
                return;
            }
            if (comboSupplier.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            for (int i = 0; i < listOrder.Count; i++)
            {
                if (listOrder[i].DatePlaced.Year > 2200)
                {
                    MsgBox.Show(this, "Not allowed to add a new order when there is already one pending.  Please finish the other order instead.");
                    return;
                }
            }
            SupplyOrder order = new SupplyOrder();

            order.SupplierNum = listSupplier[comboSupplier.SelectedIndex].SupplierNum;
            order.IsNew       = true;
            order.DatePlaced  = new DateTime(2500, 1, 1);
            order.Note        = "";
            SupplyOrders.Insert(order);
            FillGridOrder();
            gridOrder.SetSelected(listOrder.Count - 1, true);
        }
Esempio n. 3
0
        private void butNewOrder_Click(object sender, EventArgs e)
        {
            if (comboSupplier.SelectedIndex < 1)             //Includes no items or the ALL supplier being selected.
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            for (int i = 0; i < _listOrders.Count; i++)
            {
                if (_listOrders[i].DatePlaced.Year > 2200)
                {
                    MsgBox.Show(this, "Not allowed to add a new order when there is already one pending.  Please finish the other order instead.");
                    return;
                }
            }
            SupplyOrder order = new SupplyOrder();

            if (comboSupplier.SelectedIndex == 0)           //Supplier "All".
            {
                order.SupplierNum = 0;
            }
            else                                                                                 //Specific supplier selected.
            {
                order.SupplierNum = _listSuppliers[comboSupplier.SelectedIndex - 1].SupplierNum; //SelectedIndex-1 because "All" is first option.
            }
            order.IsNew      = true;
            order.DatePlaced = new DateTime(2500, 1, 1);
            order.Note       = "";
            SupplyOrders.Insert(order);
            _listOrdersAll = SupplyOrders.GetAll();          //Refresh the list all.
            FillGridOrders();
            gridOrders.SetSelected(_listOrders.Count - 1, true);
            gridOrders.ScrollToEnd();
            FillGridOrderItem();
        }
Esempio n. 4
0
        private void butNewOrder_Click(object sender, EventArgs e)
        {
            if (comboSupplier.IsAllSelected)
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            for (int i = 0; i < _listSupplyOrders.Count; i++)
            {
                if (_listSupplyOrders[i].DatePlaced.Year > 2200)
                {
                    MsgBox.Show(this, "Not allowed to add a new order when there is already one pending.  Please finish the other order instead.");
                    return;
                }
            }
            SupplyOrder order = new SupplyOrder();

            if (comboSupplier.IsAllSelected)
            {
                order.SupplierNum = 0;
            }
            else              //Specific supplier selected.
            {
                order.SupplierNum = comboSupplier.GetSelectedKey <Supplier>(x => x.SupplierNum);
            }
            order.IsNew      = true;
            order.DatePlaced = new DateTime(2300, 1, 1);
            order.Note       = "";
            order.UserNum    = 0;       //This will get set when the order is placed.
            SupplyOrders.Insert(order);
            FillGridOrders();
            gridOrders.SetSelected(_listSupplyOrders.Count - 1, true);
            gridOrders.ScrollToEnd();
            FillGridOrderItem();
        }
Esempio n. 5
0
 /// <summary>Creates a new order with all the items that have a Qty entered as a new pending order.</summary>
 private void butCreateOrdersQty_Click(object sender, EventArgs e)
 {
     //Not visible in IsSelectMode
     List<SupplyOrder> listSupplyOrders=new List<SupplyOrder>();
     SupplyOrder supplyOrder=null;
     for(int i=0;i<_listSupplies.Count;i++){
         if(_listSupplies[i].OrderQty==0){
             continue;
         }
         supplyOrder=listSupplyOrders.FirstOrDefault(x=>x.SupplierNum==_listSupplies[i].SupplierNum);
         if(supplyOrder==null){
             supplyOrder=new SupplyOrder();
             supplyOrder.SupplierNum=_listSupplies[i].SupplierNum;
             supplyOrder.IsNew=true;
             supplyOrder.DatePlaced=new DateTime(2500,1,1); //date used for new 'pending' orders.
             supplyOrder.Note="";
             supplyOrder.UserNum=Security.CurUser.UserNum;
             supplyOrder.SupplyOrderNum=SupplyOrders.Insert(supplyOrder);
             listSupplyOrders.Add(supplyOrder);
         }
         SupplyOrderItem supplyOrderItem=new SupplyOrderItem();
         supplyOrderItem.SupplyNum=_listSupplies[i].SupplyNum;
         supplyOrderItem.Qty=_listSupplies[i].OrderQty;
         supplyOrderItem.Price=_listSupplies[i].Price;
         supplyOrderItem.SupplyOrderNum=supplyOrder.SupplyOrderNum;
         SupplyOrderItems.Insert(supplyOrderItem);
         //Supply has been added to order.  Now, zero out qty on supply.
         _listSupplies[i].OrderQty=0;
         Supplies.Update(_listSupplies[i]);
     }
     if(listSupplyOrders.Count==0){
         MsgBox.Show("Please enter quantities for supplies first.");
         return;
     }
     for(int i=0;i<listSupplyOrders.Count;i++){
         SupplyOrders.UpdateOrderPrice(listSupplyOrders[i].SupplyOrderNum);
     }
     MessageBox.Show(Lan.g(this,"Done. Added ")+listSupplyOrders.Count.ToString()+Lan.g(this," orders.  Manage orders from Orders window"));
     DialogResult=DialogResult.OK;
 }