Beispiel #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;
 }
Beispiel #2
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;
 }
Beispiel #3
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;
 }
Beispiel #4
0
 public void AddSupplyFirst(Supply supply) =>
 Supplies.Insert(0, supply);