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; }
private void FormSupplies_Load(object sender, EventArgs e) { Height = SystemInformation.WorkingArea.Height; //max height Location = new Point(Location.X, 0); //move to top of screen ListSupplier = Suppliers.CreateObjects(); ListSupplyAll = Supplies.GetAll(); //Seperate GetAll() function call so that we do not copy by reference. fillComboSupplier(); FillGrid(); if (IsSelectMode) { comboSupplier.Enabled = false; //gridMain.SelectionMode=GridSelectionMode.One;//we now support multi select to add } }
private void FormSupplies_Load(object sender, EventArgs e) { this.Height = SystemInformation.WorkingArea.Height; //Resize height this.Location = new Point(Location.X, 0); //Move window to compensate for changed height ListSelectedSupplies = new List <Supply>(); _listSuppliers = Suppliers.GetAll(); _listSupplies = Supplies.GetAll(); _listSelectedSupplyNums = new List <long>(); _listSelectedSupplies = new List <Supply>(); _listSuppliesOld = new List <Supply>(); foreach (Supply supply in _listSupplies) //Make deep copy of the list so we can sync later. { _listSuppliesOld.Add(supply.Copy()); } FillComboSupplier(); FillGrid(); if (IsSelectMode) { comboSupplier.Enabled = false; } }
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; }
///<summary>Updates database based on the values in ListSupplyAll.</summary> private void saveChangesToDBHelper() { //Get all supplies from DB to check for changes.----------------------------------------------------------------- List <Supply> ListSupplyAllDB = Supplies.GetAll(); //Itterate through current supply list in memory----------------------------------------------------------------- for (int i = 0; i < ListSupplyAll.Count; i++) { //find DB version of supply to pass to UpdateOrInsertIfNeeded Supply supplyOriginal = null; for (int j = 0; j < ListSupplyAllDB.Count; j++) { if (ListSupplyAll[i].SupplyNum != ListSupplyAllDB[j].SupplyNum) { continue; //not the correct supply } supplyOriginal = ListSupplyAllDB[j]; break; //found match } Supplies.UpdateOrInsertIfNeeded(supplyOriginal, ListSupplyAll[i]); //accepts null for original. } //Update inmemory list to reflect changes. ListSupplyAll = Supplies.GetAll(); }