Ejemplo n.º 1
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            if (comboSupplier.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            Supply supp = new Supply();

            supp.IsNew       = true;
            supp.SupplierNum = ListSupplier[comboSupplier.SelectedIndex].SupplierNum;
            FormSupplyEdit FormS = new FormSupplyEdit();

            FormS.Supp         = supp;
            FormS.ListSupplier = ListSupplier;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            long selected = FormS.Supp.SupplyNum;
            int  scroll   = gridMain.ScrollValue;

            FillGrid();
            gridMain.ScrollValue = scroll;
            for (int i = 0; i < listSupply.Count; i++)
            {
                if (listSupply[i].SupplyNum == selected)
                {
                    gridMain.SetSelected(i, true);
                }
            }
        }
Ejemplo n.º 2
0
 private void butAdd_Click(object sender,EventArgs e)
 {
     if(comboSupplier.SelectedIndex==-1) {
         MsgBox.Show(this,"Please select a supplier first.");
         return;
     }
     Supply supp=new Supply();
     supp.IsNew=true;
     supp.SupplierNum=ListSupplier[comboSupplier.SelectedIndex].SupplierNum;
     FormSupplyEdit FormS=new FormSupplyEdit();
     FormS.Supp=supp;
     FormS.ListSupplier=ListSupplier;
     FormS.ShowDialog();
     if(FormS.DialogResult!=DialogResult.OK) {
         return;
     }
     long selected=FormS.Supp.SupplyNum;
     int scroll=gridMain.ScrollValue;
     FillGrid();
     gridMain.ScrollValue=scroll;
     for(int i=0;i<listSupply.Count;i++) {
         if(listSupply[i].SupplyNum==selected) {
             gridMain.SetSelected(i,true);
         }
     }
 }
Ejemplo n.º 3
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            SelectedGridItems.Clear();
            foreach (int index in gridMain.SelectedIndices)
            {
                SelectedGridItems.Add(ListSupply[index].SupplyNum);
            }
            if (IsSelectMode)
            {
                SelectedSupply = Supplies.GetSupply((long)gridMain.Rows[e.Row].Tag);
                ListSelectedSupplies.Clear();                //just in case
                for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
                {
                    ListSelectedSupplies.Add(ListSupply[gridMain.SelectedIndices[i]]);
                }
                DialogResult = DialogResult.OK;
                return;
            }
            //Supply supplyCached=Supplies.GetSupply((long)gridMain.Rows[e.Row].Tag);
            FormSupplyEdit FormS = new FormSupplyEdit();

            FormS.Supp         = Supplies.GetSupply((long)gridMain.Rows[e.Row].Tag);  //works with sorting
            FormS.ListSupplier = ListSupplier;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            ListSupplyAll = Supplies.GetAll();
            int scroll = gridMain.ScrollValue;

            FillGrid();
            gridMain.ScrollValue = scroll;
        }
Ejemplo n.º 4
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            _listSelectedSupplies.Clear();
            foreach (int index in gridMain.SelectedIndices)
            {
                _listSelectedSupplies.Add((Supply)gridMain.Rows[index].Tag);
            }
            if (IsSelectMode)
            {
                ListSelectedSupplies.Clear();                //just in case
                for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
                {
                    ListSelectedSupplies.Add((Supply)gridMain.Rows[gridMain.SelectedIndices[i]].Tag);
                }
                SyncAndClose();
                return;
            }
            Supply         selectedSupply    = (Supply)gridMain.Rows[e.Row].Tag;
            long           oldCategoryDefNum = selectedSupply.Category;
            FormSupplyEdit FormS             = new FormSupplyEdit();

            FormS.Supp         = selectedSupply;
            FormS.ListSupplier = _listSuppliers;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (FormS.Supp == null)
            {
                _listSupplies.Remove(selectedSupply);
            }
            else if (selectedSupply.Category != oldCategoryDefNum)           //If category changed
            //Send supply to the bottom the new category
            {
                _listSupplies.Remove(selectedSupply);                //Remove so we can reinsert where it needs to be.
                selectedSupply.ItemOrder = _listSupplies.FindAll(x => x.Category == selectedSupply.Category)
                                           .Select(x => x.ItemOrder)
                                           .OrderByDescending(x => x)
                                           .FirstOrDefault() + 1;//Last item in the category.
                int idx = _listSupplies.FindLastIndex(x => x.Category == selectedSupply.Category);
                if (idx == -1)
                {
                    _listSupplies.Add(selectedSupply);                    //new category, add to bottom of list
                }
                else
                {
                    _listSupplies.Insert(idx + 1, selectedSupply);                 //add to bottom of existing category
                }
            }
            int scroll = gridMain.ScrollValue;

            FillGrid();
            gridMain.ScrollValue = scroll;
        }
Ejemplo n.º 5
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            if (Defs.GetDefsForCategory(DefCat.SupplyCats, true).Count == 0)          //No supply categories have been entered, not allowed to enter supply
            {
                MsgBox.Show(this, "No supply categories have been created.  Go to the supply inventory window, select categories, and enter at least one supply category first.");
                return;
            }
            if (comboSupplier.SelectedIndex < 1)             //Includes no items or the ALL item being selected
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            Supply supp = new Supply();

            supp.IsNew       = true;
            supp.SupplierNum = _listSuppliers[comboSupplier.SelectedIndex - 1].SupplierNum;        //Selected index -1 to account for ALL being at the top of the list.
            if (gridMain.GetSelectedIndex() > -1)
            {
                supp.Category = ((Supply)gridMain.Rows[gridMain.GetSelectedIndex()].Tag).Category;
            }
            FormSupplyEdit FormS = new FormSupplyEdit();

            FormS.Supp         = supp;
            FormS.ListSupplier = _listSuppliers;
            FormS.ShowDialog();            //inserts supply in DB if needed.  Item order will be at selected index or end of category.
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (FormS.Supp == null)           //New supply deleted
            {
                return;
            }
            FormS.Supp.ItemOrder = _listSupplies.FindAll(x => x.Category == FormS.Supp.Category)
                                   .Select(x => x.ItemOrder)
                                   .OrderByDescending(x => x)
                                   .FirstOrDefault() + 1;//Last item in the category.
            int idx = _listSupplies.FindLastIndex(x => x.Category == FormS.Supp.Category);

            if (idx == -1)
            {
                _listSupplies.Add(FormS.Supp);                //new category, add to bottom of list
            }
            else
            {
                _listSupplies.Insert(idx + 1, FormS.Supp);             //add to bottom of existing category
            }
            FillGrid();
        }
Ejemplo n.º 6
0
        private void butNewSupply_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 (DefC.Short[(int)DefCat.SupplyCats].Length == 0)
            {
                MsgBox.Show(this, "Please add supply categories first.  Use the menu at the top of this window.");
                return;
            }
            if (comboSupplier.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            Supply supp = new Supply();

            supp.IsNew       = true;
            supp.SupplierNum = listSupplier[comboSupplier.SelectedIndex].SupplierNum;
            FormSupplyEdit FormS = new FormSupplyEdit();

            FormS.Supp         = supp;
            FormS.ListSupplier = listSupplier;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            long selected = FormS.Supp.SupplyNum;
            int  scroll   = gridSupplyMain.ScrollValue;

            FillGridSupplyMain();
            gridSupplyMain.ScrollValue = scroll;
            for (int i = 0; i < listSupply.Count; i++)
            {
                if (listSupply[i].SupplyNum == selected)
                {
                    gridSupplyMain.SetSelected(i, true);
                }
            }
        }
Ejemplo n.º 7
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            if (DefC.Short[(int)DefCat.SupplyCats].Length == 0)           //No supply categories have been entered, not allowed to enter supply
            {
                MsgBox.Show(this, "No supply categories have been created.  Go to the supply inventory window, select categories, and enter at least one supply category first.");
                return;
            }
            if (comboSupplier.SelectedIndex < 1)             //Includes no items or the ALL item being selected
            {
                MsgBox.Show(this, "Please select a supplier first.");
                return;
            }
            Supply supp = new Supply();

            supp.IsNew       = true;
            supp.SupplierNum = ListSupplier[comboSupplier.SelectedIndex - 1].SupplierNum;        //Selected index -1 to account for ALL being at the top of the list.
            if (gridMain.GetSelectedIndex() > -1)
            {
                supp.Category  = ListSupply[gridMain.GetSelectedIndex()].Category;
                supp.ItemOrder = ListSupply[gridMain.GetSelectedIndex()].ItemOrder;
            }
            FormSupplyEdit FormS = new FormSupplyEdit();

            FormS.Supp         = supp;
            FormS.ListSupplier = ListSupplier;
            FormS.ShowDialog();            //inserts supply in DB if needed.  Item order will be at selected index or end of category.
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            //update listSupplyAll to reflect changes made to DB.
            ListSupplyAll = Supplies.GetAll();
            //int scroll=gridMain.ScrollValue;
            SelectedGridItems.Clear();
            SelectedGridItems.Add(FormS.Supp.SupplyNum);
            FillGrid();
            //gridMain.ScrollValue=scroll;
        }
Ejemplo n.º 8
0
 private void gridMain_CellDoubleClick(object sender,ODGridClickEventArgs e)
 {
     if(IsSelectMode){
         ListSuppliesSelected=new List<Supply>();
         ListSuppliesSelected.Add(_listSupplies[e.Row]);
         DialogResult=DialogResult.OK;
         return;
     }
     FormSupplyEdit formSupplyEdit=new FormSupplyEdit();
     formSupplyEdit.ListSuppliers=_listSuppliers;
     formSupplyEdit.SupplyCur=_listSupplies[e.Row];
     formSupplyEdit.ShowDialog();
     if(formSupplyEdit.DialogResult!=DialogResult.OK) {
         return;
     }
     FillGrid();
     for(int i=0;i<_listSupplies.Count;i++){
         if(_listSupplies[i].SupplyNum==formSupplyEdit.SupplyCur.SupplyNum){
             gridMain.SetSelected(i,true);
             return;
         }
     }
 }
Ejemplo n.º 9
0
        private void gridSupplyMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            FormSupplyEdit FormS = new FormSupplyEdit();

            FormS.Supp         = listSupply[e.Row];
            FormS.ListSupplier = listSupplier;
            FormS.ShowDialog();
            if (FormS.DialogResult != DialogResult.OK)
            {
                return;
            }
            long selected = listSupply[e.Row].SupplyNum;
            int  scroll   = gridSupplyMain.ScrollValue;

            FillGridSupplyMain();
            gridSupplyMain.ScrollValue = scroll;
            for (int i = 0; i < listSupply.Count; i++)
            {
                if (listSupply[i].SupplyNum == selected)
                {
                    gridSupplyMain.SetSelected(i, true);
                }
            }
        }
Ejemplo n.º 10
0
 private void butAdd_Click(object sender,EventArgs e)
 {
     if(Defs.GetDefsForCategory(DefCat.SupplyCats,true).Count==0) {
         MsgBox.Show(this,"No supply categories have been created.  Go to the supply inventory window, select categories, and enter at least one supply category first.");
         return;
     }
     if(_listSuppliers.Count==0) {
         MsgBox.Show(this,"No suppliers have been created.  Go to the suppliers window to add suppliers first.");
         return;
     }
     if(comboSuppliers.IsAllSelected || comboSuppliers.SelectedIndices.Count==0){
         MsgBox.Show(this,"Please select one supplier, first.");//because supplier can't ever change, so they need to be looking at just one supplier.
         //an enhancement would be to let them pick a supplier for a new supply, but then not edit.
         return;
     }
     FormSupplyEdit formSupplyEdit=new FormSupplyEdit();
     formSupplyEdit.ListSuppliers=_listSuppliers;
     Supply supply=new Supply();
     //category:
     if(gridMain.SelectedIndices.Length>0){
         supply.Category=_listSupplies[gridMain.SelectedIndices[0]].Category;
     }
     else if(comboCategories.IsAllSelected || comboCategories.SelectedIndices.Count==0){
         supply.Category=((Def)comboCategories.Items.GetObjectAt(0)).DefNum;
     }
     else{
         supply.Category=((Def)comboCategories.Items.GetObjectAt(comboCategories.SelectedIndices[0])).DefNum;
     }
     //supplier:
     supply.SupplierNum=_listSuppliers[comboSuppliers.SelectedIndices[0]].SupplierNum;
     //itemOrder:
     if(gridMain.SelectedIndices.Length>0){
         supply.ItemOrder=_listSupplies[gridMain.SelectedIndices[0]].ItemOrder;
         //even if many items are hidden for various reasons, this works.  Query at bottom of this method blindly moves all the others down.
     }
     else{
         //nothing is selected, so we'll just add it to the end of whatever category we picked above, typically the first category.
         supply.ItemOrder=Supplies.GetLastItemOrder(supply.Category)+1;
         //The query below will then just do nothing because no ItemOrders below
     }
     supply.IsNew=true;
     formSupplyEdit.SupplyCur=supply;
     formSupplyEdit.ShowDialog();
     if(formSupplyEdit.DialogResult!=DialogResult.OK) {
         return;
     }
     //move other item orders down
     Supplies.OrderAddOneGreater(supply.ItemOrder,formSupplyEdit.SupplyCur.Category,formSupplyEdit.SupplyCur.SupplyNum);//example added at 3, so ++ item orders >=3
     int selected=-1;
     if(gridMain.SelectedIndices.Length>0){
         selected=gridMain.SelectedIndices[0];
     }
     FillGrid();
     if(selected!=-1){
         gridMain.SetSelected(selected,true);
         return;
     }
     //none was selected, but we want to select the new item.
     for(int i=0;i<_listSupplies.Count;i++){
         if(_listSupplies[i].SupplyNum==formSupplyEdit.SupplyCur.SupplyNum){
             gridMain.SetSelected(i,true);
             return;
         }
     }
 }
Ejemplo n.º 11
0
 private void gridSupplyMain_CellDoubleClick(object sender,ODGridClickEventArgs e)
 {
     FormSupplyEdit FormS=new FormSupplyEdit();
     FormS.Supp=listSupply[e.Row];
     FormS.ListSupplier=listSupplier;
     FormS.ShowDialog();
     if(FormS.DialogResult!=DialogResult.OK) {
         return;
     }
     long selected=listSupply[e.Row].SupplyNum;
     int scroll=gridSupplyMain.ScrollValue;
     FillGridSupplyMain();
     gridSupplyMain.ScrollValue=scroll;
     for(int i=0;i<listSupply.Count;i++) {
         if(listSupply[i].SupplyNum==selected) {
             gridSupplyMain.SetSelected(i,true);
         }
     }
 }
Ejemplo n.º 12
0
 private void butNewSupply_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(DefC.Short[(int)DefCat.SupplyCats].Length==0) {
         MsgBox.Show(this,"Please add supply categories first.  Use the menu at the top of this window.");
         return;
     }
     if(comboSupplier.SelectedIndex==-1) {
         MsgBox.Show(this,"Please select a supplier first.");
         return;
     }
     Supply supp=new Supply();
     supp.IsNew=true;
     supp.SupplierNum=listSupplier[comboSupplier.SelectedIndex].SupplierNum;
     FormSupplyEdit FormS=new FormSupplyEdit();
     FormS.Supp=supp;
     FormS.ListSupplier=listSupplier;
     FormS.ShowDialog();
     if(FormS.DialogResult!=DialogResult.OK) {
         return;
     }
     long selected=FormS.Supp.SupplyNum;
     int scroll=gridSupplyMain.ScrollValue;
     FillGridSupplyMain();
     gridSupplyMain.ScrollValue=scroll;
     for(int i=0;i<listSupply.Count;i++) {
         if(listSupply[i].SupplyNum==selected) {
             gridSupplyMain.SetSelected(i,true);
         }
     }
 }
Ejemplo n.º 13
0
		private void gridMain_CellDoubleClick(object sender,ODGridClickEventArgs e) {
			SelectedGridItems.Clear();
			foreach(int index in gridMain.SelectedIndices) {
				SelectedGridItems.Add(ListSupply[index].SupplyNum);
			}
			if(IsSelectMode) {
				SelectedSupply = Supplies.GetSupply((long)gridMain.Rows[e.Row].Tag);
				ListSelectedSupplies.Clear();//just in case
				for(int i=0;i<gridMain.SelectedIndices.Length;i++) {
					ListSelectedSupplies.Add(ListSupply[gridMain.SelectedIndices[i]]);
				}				
				DialogResult = DialogResult.OK;
				return;
			}
			//Supply supplyCached=Supplies.GetSupply((long)gridMain.Rows[e.Row].Tag);
			FormSupplyEdit FormS=new FormSupplyEdit();
			FormS.Supp=Supplies.GetSupply((long)gridMain.Rows[e.Row].Tag);//works with sorting
			FormS.ListSupplier=ListSupplier;
			FormS.ShowDialog();
			if(FormS.DialogResult!=DialogResult.OK) {
				return;	
			}
			ListSupplyAll=Supplies.GetAll();
			int scroll=gridMain.ScrollValue;
			FillGrid();
			gridMain.ScrollValue=scroll;
		}
Ejemplo n.º 14
0
		private void butAdd_Click(object sender,EventArgs e) {
			if(DefC.Short[(int)DefCat.SupplyCats].Length==0) {//No supply categories have been entered, not allowed to enter supply
				MsgBox.Show(this,"No supply categories have been created.  Go to the supply inventory window, select categories, and enter at least one supply category first.");
				return;
			}
			if(comboSupplier.SelectedIndex < 1) {//Includes no items or the ALL item being selected
				MsgBox.Show(this,"Please select a supplier first.");
				return;
			}
			Supply supp=new Supply();
			supp.IsNew=true;
			supp.SupplierNum=ListSupplier[comboSupplier.SelectedIndex-1].SupplierNum;//Selected index -1 to account for ALL being at the top of the list.
			if(gridMain.GetSelectedIndex()>-1){
				supp.Category=ListSupply[gridMain.GetSelectedIndex()].Category;
				supp.ItemOrder=ListSupply[gridMain.GetSelectedIndex()].ItemOrder;
			}
			FormSupplyEdit FormS=new FormSupplyEdit();
			FormS.Supp=supp;
			FormS.ListSupplier=ListSupplier;
			FormS.ShowDialog();//inserts supply in DB if needed.  Item order will be at selected index or end of category.
			if(FormS.DialogResult!=DialogResult.OK) {
				return;
			}
			//update listSupplyAll to reflect changes made to DB.
			ListSupplyAll=Supplies.GetAll();
			//int scroll=gridMain.ScrollValue;
			SelectedGridItems.Clear();
			SelectedGridItems.Add(FormS.Supp.SupplyNum);
			FillGrid();
			//gridMain.ScrollValue=scroll;
		}