示例#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.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;
 }
示例#2
0
        private void FillGridSupplyMain()
        {
            long supplier = 0;

            if (comboSupplier.SelectedIndex != -1)
            {
                supplier = listSupplier[comboSupplier.SelectedIndex].SupplierNum;
            }
            listSupply = Supplies.CreateObjects(checkShowHidden.Checked, supplier, textFind.Text);
            gridSupplyMain.BeginUpdate();
            gridSupplyMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g(this, "Category"), 130);

            gridSupplyMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Catalog #"), 80);
            gridSupplyMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Description"), 340);
            gridSupplyMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "Price"), 60, HorizontalAlignment.Right);
            gridSupplyMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "StockQty"), 60, HorizontalAlignment.Center);
            gridSupplyMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g(this, "IsHidden"), 40, HorizontalAlignment.Center);
            gridSupplyMain.Columns.Add(col);
            gridSupplyMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < listSupply.Count; i++)
            {
                row = new ODGridRow();
                if (i == 0 || listSupply[i].Category != listSupply[i - 1].Category)
                {
                    row.Cells.Add(DefC.GetName(DefCat.SupplyCats, listSupply[i].Category));
                }
                else
                {
                    row.Cells.Add("");
                }
                row.Cells.Add(listSupply[i].CatalogNumber);
                row.Cells.Add(listSupply[i].Descript);
                if (listSupply[i].Price == 0)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(listSupply[i].Price.ToString("n"));
                }
                if (listSupply[i].LevelDesired == 0)
                {
                    row.Cells.Add("");
                }
                else
                {
                    row.Cells.Add(listSupply[i].LevelDesired.ToString());
                }
                if (listSupply[i].IsHidden)
                {
                    row.Cells.Add("X");
                }
                else
                {
                    row.Cells.Add("");
                }
                //row.Cells.Add(listSupply[i].ItemOrder.ToString());
                gridSupplyMain.Rows.Add(row);
            }
            gridSupplyMain.EndUpdate();
        }