Exemple #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;
 }
        private void butAddSupply_Click(object sender, EventArgs e)
        {
            if (gridOrders.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a supply order to add items to first.");
                return;
            }
            FormSupplies FormSup = new FormSupplies();

            FormSup.IsSelectMode        = true;
            FormSup.SelectedSupplierNum = _listOrders[gridOrders.GetSelectedIndex()].SupplierNum;
            FormSup.ShowDialog();
            if (FormSup.DialogResult != DialogResult.OK)
            {
                return;
            }

            for (int i = 0; i < FormSup.ListSelectedSupplies.Count; i++)
            {
                //check for existing----
                if (_tableOrderItems.Rows.OfType <DataRow>().Any(x => PIn.Long(x["SupplyNum"].ToString()) == FormSup.ListSelectedSupplies[i].SupplyNum))
                {
                    //MsgBox.Show(this,"Selected item already exists in currently selected order. Please edit quantity instead.");
                    continue;
                }
                SupplyOrderItem orderitem = new SupplyOrderItem();
                orderitem.SupplyNum      = FormSup.ListSelectedSupplies[i].SupplyNum;
                orderitem.Qty            = 1;
                orderitem.Price          = FormSup.ListSelectedSupplies[i].Price;
                orderitem.SupplyOrderNum = _listOrders[gridOrders.GetSelectedIndex()].SupplyOrderNum;
                //soi.SupplyOrderItemNum
                SupplyOrderItems.Insert(orderitem);
            }
            UpdatePriceAndRefresh();
        }
Exemple #3
0
        private void butAddSupply_Click(object sender, EventArgs e)
        {
            if (gridOrders.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select a supply order to add items to first.");
                return;
            }
            FormSupplies FormSup = new FormSupplies();

            FormSup.IsSelectMode        = true;
            FormSup.SelectedSupplierNum = ListOrders[gridOrders.GetSelectedIndex()].SupplierNum;
            FormSup.ShowDialog();
            if (FormSup.DialogResult != DialogResult.OK)
            {
                return;
            }

            for (int i = 0; i < FormSup.ListSelectedSupplies.Count; i++)
            {
                //check for existing----
                if (itemExistsHelper(FormSup.ListSelectedSupplies[i]))
                {
                    //MsgBox.Show(this,"Selected item already exists in currently selected order. Please edit quantity instead.");
                    continue;
                }
                SupplyOrderItem orderitem = new SupplyOrderItem();
                orderitem.SupplyNum      = FormSup.ListSelectedSupplies[i].SupplyNum;
                orderitem.Qty            = 1;
                orderitem.Price          = FormSup.ListSelectedSupplies[i].Price;
                orderitem.SupplyOrderNum = ListOrders[gridOrders.GetSelectedIndex()].SupplyOrderNum;
                //soi.SupplyOrderItemNum
                SupplyOrderItems.Insert(orderitem);
            }
            FillGridOrderItem();
        }
Exemple #4
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;
 }
Exemple #5
0
        private void butAddToOrder_Click(object sender, EventArgs e)
        {
            if (gridOrder.GetSelectedIndex() == -1)
            {
                MsgBox.Show(this, "Please select an order first.");
                return;
            }
            if (gridSupplyMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select one or more supplies first.");
                return;
            }
            SupplyOrderItem item;
            List <long>     itemNums        = new List <long>();
            List <Supply>   skippedSupplies = new List <Supply>();
            bool            isSkipped;

            for (int i = 0; i < gridSupplyMain.SelectedIndices.Length; i++)
            {
                isSkipped = false;
                for (int t = 0; t < tableOrderItem.Rows.Count; t++)
                {
                    if (listSupply[gridSupplyMain.SelectedIndices[i]].SupplyNum.ToString() == tableOrderItem.Rows[t]["SupplyNum"].ToString())
                    {
                        isSkipped = true;
                        break;;
                    }
                }
                if (isSkipped)
                {
                    skippedSupplies.Add(listSupply[gridSupplyMain.SelectedIndices[i]]);
                    continue;
                }
                item = new SupplyOrderItem();
                item.SupplyOrderNum = listOrder[gridOrder.GetSelectedIndex()].SupplyOrderNum;
                item.SupplyNum      = listSupply[gridSupplyMain.SelectedIndices[i]].SupplyNum;
                item.Qty            = 1;
                item.Price          = listSupply[gridSupplyMain.SelectedIndices[i]].Price;
                SupplyOrderItems.Insert(item);
                itemNums.Add(item.SupplyOrderItemNum);
            }
            if (gridSupplyMain.SelectedIndices.Length == 1 && skippedSupplies.Count == 1)
            {
                MsgBox.Show(this, "Selected supply is already on the order.");
                return;
            }
            else if (skippedSupplies.Count == gridSupplyMain.SelectedIndices.Length)
            {
                MsgBox.Show(this, "Selected supplies are already on the order.");
                return;
            }
            else if (skippedSupplies.Count > 0)
            {
                MessageBox.Show(skippedSupplies.Count.ToString() + " " + Lan.g(this, "supplies were skipped because they are already on the order."));
            }
            FillGridOrderItem();
            tabControl.SelectedIndex = 1;
            for (int i = 0; i < tableOrderItem.Rows.Count; i++)
            {
                if (itemNums.Contains(PIn.Long(tableOrderItem.Rows[i]["SupplyOrderItemNum"].ToString())))
                {
                    gridOrderItem.SetSelected(i, true);
                }
            }
        }