示例#1
0
        private void butUp_Click(object sender, EventArgs e)
        {
            //Nothing Selected
            if (gridMain.SelectedIndices.Length == 0)
            {
                return;
            }
            //remember selected SupplyNums for later
            SelectedGridItems.Clear();
            foreach (int index in gridMain.SelectedIndices)
            {
                SelectedGridItems.Add(ListSupply[index].SupplyNum);
            }
            if (Supplies.CleanupItemOrders(ListSupplyAll))             //should only have to run once more... after code updates to supply window.
            {
                MsgBox.Show(this, "There was a problem with sorting, but it has been fixed.  You may now try again.");
                FillGrid();
                return;
            }
            //loop through selected indicies, moving each one as needed, no saves to the database until after all items are moved.
            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                int index     = gridMain.SelectedIndices[i];          //to reduce confusion
                int itemOrder = ListSupply[index].ItemOrder;          //to reduce confusion
                //Top of category---------------------------------------------------------------------------------------
                if (itemOrder == 0)
                {
                    continue;                    //already top of category
                }
                //Top of visible category but not actually top of category----------------------------------------------
                if (index == 0 ||           //topmost item in visible list
                    ListSupply[index].Category != ListSupply[index - 1].Category) //topmost item in category in visible list
                {
                    moveItemOrderHelper(ListSupply[index], 0);                    //move item to top of respective category.
                    continue;
                }
                //Item is directly below a selected item in same category-----------------------------------------------
                if (indexIsSelectedHelper(index - 1))                                            //check for same category is performed above
                {
                    moveItemOrderHelper(ListSupply[index], ListSupply[index - 1].ItemOrder + 1); //move this item after the item above it, because both are selected.
                    continue;
                }
                //Item is directly below a non-selected item in same category-------------------------------------------
                //check for same category is performed above.
                moveItemOrderHelper(ListSupply[index], ListSupply[index - 1].ItemOrder);
            }
            saveChangesToDBHelper();
            ListSupplyAll.Sort(sortSupplyListByCategoryOrderThenItemOrder);
            int scrollVal = gridMain.ScrollValue;

            FillGrid();
            gridMain.ScrollValue = scrollVal;
        }
示例#2
0
        private void butDown_Click(object sender, EventArgs e)
        {
            //Nothing Selected
            if (gridMain.SelectedIndices.Length == 0)
            {
                return;
            }
            //remember selected SupplyNums for later
            SelectedGridItems.Clear();
            foreach (int index in gridMain.SelectedIndices)
            {
                SelectedGridItems.Add(ListSupply[index].SupplyNum);
            }
            if (Supplies.CleanupItemOrders(ListSupplyAll))             //should only have to run once more... after code updates to supply window.
            {
                MsgBox.Show(this, "There was a problem with sorting, but it has been fixed.  You may now try again.");
                FillGrid();
                return;
            }
            for (int i = gridMain.SelectedIndices.Length - 1; i >= 0; i--)
            {
                int index     = gridMain.SelectedIndices[i];          //to reduce confusion
                int itemOrder = ListSupply[index].ItemOrder;          //to reduce confusion
                //Bottom----------------------------------------------
                if (index == ListSupply.Count - 1 ||         //bottommost item in visible list
                    ListSupply[index].Category != ListSupply[index + 1].Category)                    //bottommost item in category in visible list
                {
                    //end of list or category already.
                    continue;
                }
                //Item is directly above a selected item in same category-----------------------------------------------
                if (indexIsSelectedHelper(index + 1))                                            //check for same category is performed above
                {
                    moveItemOrderHelper(ListSupply[index], ListSupply[index + 1].ItemOrder - 1); //move this item after the item above it, because both are selected.
                    continue;
                }
                //Item is directly below a non-selected item in same category-------------------------------------------
                //check for same category is performed above.
                moveItemOrderHelper(ListSupply[index], ListSupply[index + 1].ItemOrder);
            }
            saveChangesToDBHelper();
            ListSupplyAll.Sort(sortSupplyListByCategoryOrderThenItemOrder);
            int scrollVal = gridMain.ScrollValue;

            FillGrid();
            gridMain.ScrollValue = scrollVal;
        }
示例#3
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;
 }
示例#4
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;
        }