示例#1
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textLevelDesired.errorProvider1.GetError(textLevelDesired) != "" ||
         textPrice.errorProvider1.GetError(textPrice) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDescript.Text == "")
     {
         MsgBox.Show(this, "Please enter a description.");
         return;
     }
     Supp.Category      = DefC.Short[(int)DefCat.SupplyCats][comboCategory.SelectedIndex].DefNum;
     Supp.CatalogNumber = textCatalogNumber.Text;
     Supp.Descript      = textDescript.Text;
     Supp.LevelDesired  = PIn.Float(textLevelDesired.Text);
     Supp.Price         = PIn.Double(textPrice.Text);
     Supp.IsHidden      = checkIsHidden.Checked;
     if (Supp.Category != categoryInitialVal)
     {
         Supp.ItemOrder = int.MaxValue;              //changed categories, new or existing, move to bottom of new category.
     }
     if (Supp.IsNew)
     {
         Supp = Supplies.GetSupply(Supplies.Insert(Supp, Supp.ItemOrder));             //insert Supp and update with PK and item order from DB.
     }
     else
     {
         Supplies.Update(SuppOriginal, Supp);
     }
     DialogResult = DialogResult.OK;
 }
示例#2
0
 ///<summary>Fixes all ItemOrders for a category where a duplicate was found.  Includes IsHidden so that it works for both hidden and unhidden.</summary>
 private void FixItemOrders(long category)
 {
     List<long> listCategories=new List<long>();
     listCategories.Add(category);
     List<Supply> listSuppliesCat=Supplies.GetList(null,true,"",listCategories);
     for(int i=0;i<listSuppliesCat.Count;i++){
         if(listSuppliesCat[i].ItemOrder!=i){
             listSuppliesCat[i].ItemOrder=i;
             Supplies.Update(listSuppliesCat[i]);
         }
     }
 }
示例#3
0
        /*
        private void checkShowShoppingList_Click(object sender,EventArgs e) {
            _listSelectedSupplies.Clear();
            foreach(int index in gridMain.SelectedIndices) {
                _listSelectedSupplies.Add((Supply)gridMain.ListGridRows[index].Tag);
            }
            FillGrid();
        }*/
        private void butUp_Click(object sender,EventArgs e)
        {
            if(textFind.Text!=""){
                MsgBox.Show(this,"Not allowed unless search text is empty.");
                return;
            }
            if(!comboSuppliers.IsAllSelected){
                MsgBox.Show(this,"Not allowed unless All suppliers are selected.");
                return;
            }
            List<int> listSelected=gridMain.SelectedIndices.ToList<int>();
            if(listSelected.Count==0){
                MsgBox.Show(this,"Please select at least one supply, first.");
                return;
            }
            for(int i=1;i<listSelected.Count;i++) {
                if(_listSupplies[listSelected[0]].Category != _listSupplies[listSelected[i]].Category){
                    MsgBox.Show(this,"All selected supplies must be in the same category.");
                    return;
                }
                if(listSelected[i-1]+1 != listSelected[i]){
                    MsgBox.Show(this,"Selection must not have gaps.");//makes my math too hard
                    return;
                }
            }
            if(listSelected[0]==0){
                return;//already at top
            }
            if(_listSupplies[listSelected[0]].Category != _listSupplies[listSelected[0]-1].Category){
                MsgBox.Show(this,"Already at top of category.");
                return;
            }
            //we should only have to move them up one, but there could be hidden supplies that would require moving up more.
            //There can also be hidden supplies that cause gaps in our selected list.
            //After considering many options, the best solution is to move group up one, and then set the item above to the ItemOrder of the bottom in group.

            int countMove=_listSupplies[listSelected[0]].ItemOrder-_listSupplies[listSelected[0]-1].ItemOrder;//example 2-1=1
            //todo: fix gaps caused by hidden supplies

            List<long> listSupplyNums=new List<long>();
            for(int i=0;i<listSelected.Count;i++) {
                listSupplyNums.Add(_listSupplies[listSelected[i]].SupplyNum);
            }
            Supplies.OrderSubtract(listSupplyNums,countMove);
            _listSupplies[listSelected[0]-1].ItemOrder+=listSelected.Count+countMove-1;//Example 0+5+1-1=5, while the 5 selected items moved up to occupy 0 through 4.
            Supplies.Update(_listSupplies[listSelected[0]-1]);
            FillGrid();
            int[] indicesNew=new int[listSelected.Count];
            for(int i=0;i<listSelected.Count;i++){
                indicesNew[i]=listSelected[i]-1;
            }
            gridMain.SetSelected(indicesNew,true);
        }
示例#4
0
 private void butDown_Click(object sender,EventArgs e)
 {
     if(textFind.Text!=""){
         MsgBox.Show(this,"Not allowed unless search text is empty.");
         return;
     }
     if(!comboSuppliers.IsAllSelected){
         MsgBox.Show(this,"Not allowed unless All suppliers are selected.");
         return;
     }
     List<int> listSelected=gridMain.SelectedIndices.ToList<int>();
     if(listSelected.Count==0){
         MsgBox.Show(this,"Please select at least one supply, first.");
         return;
     }
     for(int i=1;i<listSelected.Count;i++) {
         if(_listSupplies[listSelected[0]].Category != _listSupplies[listSelected[i]].Category){
             MsgBox.Show(this,"All selected supplies must be in the same category.");
             return;
         }
         if(listSelected[i-1]+1 != listSelected[i]){
             MsgBox.Show(this,"Selection must not have gaps.");//makes my math too hard
             return;
         }
     }
     if(listSelected[listSelected.Count-1]==_listSupplies.Count-1){
         return;//already at bottom
     }
     if(_listSupplies[listSelected[listSelected.Count-1]].Category
         != _listSupplies[listSelected[listSelected.Count-1]+1].Category){
         MsgBox.Show(this,"Already at bottom of category.");
         return;
     }
     int countMove=_listSupplies[listSelected[listSelected.Count-1]+1].ItemOrder-_listSupplies[listSelected[listSelected.Count-1]].ItemOrder;//example 5-4=1
     List<long> listSupplyNums=new List<long>();
     for(int i=0;i<listSelected.Count;i++) {
         listSupplyNums.Add(_listSupplies[listSelected[i]].SupplyNum);
     }
     Supplies.OrderAdd(listSupplyNums,countMove);
     _listSupplies[listSelected[listSelected.Count-1]+1].ItemOrder
         -=listSelected.Count+countMove-1;//Example 5-5+1-1=0, while the 5 selected items moved down to occupy 1 through 5.
     Supplies.Update(_listSupplies[listSelected[listSelected.Count-1]+1]);
     FillGrid();
     int[] indicesNew=new int[listSelected.Count];
     for(int i=0;i<listSelected.Count;i++){
         indicesNew[i]=listSelected[i]+1;
     }
     gridMain.SetSelected(indicesNew,true);
 }
示例#5
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textLevelDesired.errorProvider1.GetError(textLevelDesired) != "" ||
         textPrice.errorProvider1.GetError(textPrice) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDescript.Text == "")
     {
         MsgBox.Show(this, "Please enter a description.");
         return;
     }
     Supp.Category      = DefC.Short[(int)DefCat.SupplyCats][comboCategory.SelectedIndex].DefNum;
     Supp.CatalogNumber = textCatalogNumber.Text;
     Supp.Descript      = textDescript.Text;
     Supp.LevelDesired  = PIn.Float(textLevelDesired.Text);
     Supp.Price         = PIn.Double(textPrice.Text);
     Supp.IsHidden      = checkIsHidden.Checked;
     if (Supp.IsHidden != isHiddenInitialVal)
     {
         if (Supp.IsHidden)
         {
             Supp.ItemOrder = 0;
         }
         else
         {
             Supp.ItemOrder = Supplies.GetLastItemOrder(Supp.SupplierNum, Supp.Category) + 1;
         }
     }
     if (Supp.IsNew)
     {
         Supplies.Insert(Supp);
     }
     else
     {
         Supplies.Update(Supp);
     }
     if (Supp.IsHidden != isHiddenInitialVal || Supp.Category != categoryInitialVal)
     {
         List <Supply> listSupply = Supplies.CreateObjects(false, Supp.SupplierNum, "");
         Supplies.CleanupItemOrders(listSupply);
     }
     DialogResult = DialogResult.OK;
 }
示例#6
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;
 }
示例#7
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textLevelDesired.errorProvider1.GetError(textLevelDesired) != "" ||
         textPrice.errorProvider1.GetError(textPrice) != "" ||
         textOrderQty.errorProvider1.GetError(textOrderQty) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textDescript.Text == "")
     {
         MsgBox.Show(this, "Please enter a description.");
         return;
     }
     SupplyCur.Category      = comboCategory.GetSelectedDefNum();
     SupplyCur.CatalogNumber = textCatalogNumber.Text;
     SupplyCur.Descript      = textDescript.Text;
     SupplyCur.LevelDesired  = PIn.Float(textLevelDesired.Text);
     SupplyCur.OrderQty      = PIn.Int(textOrderQty.Text);
     SupplyCur.Price         = PIn.Double(textPrice.Text);
     //the logic below handles some of the basics.  This is supplemented in some cases by the automatic order fixing.
     if (!SupplyCur.IsHidden && checkIsHidden.Checked) //hiding
     {
         SupplyCur.ItemOrder = 0;                      //not perfect.  Hidden get intermingled with the first item.
     }
     if (SupplyCur.IsHidden && !checkIsHidden.Checked) //unhiding
     {
         SupplyCur.ItemOrder = 0;                      //keeps it at top of list
     }
     SupplyCur.IsHidden = checkIsHidden.Checked;
     if (SupplyCur.IsNew)
     {
         SupplyCur.SupplyNum = Supplies.Insert(SupplyCur);
     }
     else
     {
         Supplies.Update(SupplyCur);
     }
     DialogResult = DialogResult.OK;
 }
示例#8
0
 private void gridMain_CellLeave(object sender, ODGridClickEventArgs e)
 {
     if(!checkEnterQty.Checked){
         return;
     }
     if(e.Col!=6){
         return;
     }
     int qtyOld=_listSupplies[e.Row].OrderQty;
     int qtyNew=0;
     try {
         qtyNew=PIn.Int(gridMain.ListGridRows[e.Row].Cells[6].Text);//0 if not valid input
     }
     catch { }
     if(qtyOld==qtyNew){
         FillGrid(false);//no refresh
     }
     else{
         _listSupplies[e.Row].OrderQty=qtyNew;
         Supplies.Update(_listSupplies[e.Row]);
         FillGrid();
     }
 }
示例#9
0
        private void butDown_Click(object sender, EventArgs e)
        {
            if (!IsCleanRefresh)
            {
                MsgBox.Show(this, "Please perform a clean refresh first without any find text.");
                return;
            }
            if (gridSupplyMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "You must first select at least one row.");
                return;
            }
            textFind.Text = "";
            if (Supplies.CleanupItemOrders(listSupply))
            {
                MsgBox.Show(this, "There was a problem with sorting, but it has been fixed.  You may now try again.");
                FillGridSupplyMain();
                return;
            }
            for (int i = 0; i < gridSupplyMain.SelectedIndices.Length; i++)
            {
                if (listSupply[gridSupplyMain.SelectedIndices[0]].Category != listSupply[gridSupplyMain.SelectedIndices[i]].Category)
                {
                    MsgBox.Show(this, "You may only move items that are in the same category.");
                    return;
                }
            }
            if (gridSupplyMain.SelectedIndices[gridSupplyMain.SelectedIndices.Length - 1] == listSupply.Count - 1 ||
                listSupply[gridSupplyMain.SelectedIndices[gridSupplyMain.SelectedIndices.Length - 1]].Category
                != listSupply[gridSupplyMain.SelectedIndices[gridSupplyMain.SelectedIndices.Length - 1] + 1].Category)
            {
                return;                //already at the bottom
            }
            //remember the selected SupplyNums for rehighlighting later.
            List <long> selectedSupplyNums = new List <long>();

            for (int i = 0; i < gridSupplyMain.SelectedIndices.Length; i++)
            {
                selectedSupplyNums.Add(listSupply[gridSupplyMain.SelectedIndices[i]].SupplyNum);
            }
            int scrollVal = gridSupplyMain.ScrollValue;

            //change all the appropriate itemorders in the main list
            for (int i = gridSupplyMain.SelectedIndices.Length - 1; i >= 0; i--)     //loop from the bottom up
            //move the one below it up
            {
                listSupply[gridSupplyMain.SelectedIndices[i] + 1].ItemOrder--;
                Supplies.Update(listSupply[gridSupplyMain.SelectedIndices[i] + 1]);
                //move this one down
                listSupply[gridSupplyMain.SelectedIndices[i]].ItemOrder++;
                Supplies.Update(listSupply[gridSupplyMain.SelectedIndices[i]]);
                listSupply.Reverse(gridSupplyMain.SelectedIndices[i], 2);
            }
            FillGridSupplyMain();
            //reselect the original supplyNums
            for (int i = 0; i < listSupply.Count; i++)
            {
                if (selectedSupplyNums.Contains(listSupply[i].SupplyNum))
                {
                    gridSupplyMain.SetSelected(i, true);
                }
            }
            gridSupplyMain.ScrollValue = scrollVal;
        }