public List <Vendor> GetBySubCategoryUse(ProductSubCategoryId subCategoryId)
 {
     return(Search("dbo.GetVendorsBySubCategoryUse", delegate(SqlCommand cmd)
     {
         SqlHelper.AddParamInputId(cmd, "@ProductSubCategoryId", subCategoryId.Value);
     }));
 }
Beispiel #2
0
        private void btnSetSubcategories_Click(object sender, EventArgs e)
        {
            bool onFirstRow = true;
            ProductSubCategoryId subCatId = null;
            int numberSet     = 0;
            int numberSkipped = 0;
            List <DataGridViewRow> sortedRows = new List <DataGridViewRow>();

            foreach (DataGridViewRow row in grdLines.SelectedRows)
            {
                sortedRows.Add(row);
            }
            sortedRows.Sort((r1, r2) => r1.Index.CompareTo(r2.Index));
            foreach (DataGridViewRow row in sortedRows)
            {
                JoinPlToVpToProd purLine = (JoinPlToVpToProd)row.DataBoundItem;
                if (onFirstRow)
                {
                    subCatId = purLine.PurLine_ProductSubCategoryId;
                    ProductSubCategory subCat = mSubCategoriesById[subCatId.Value];
                    string             prompt = "Use subcategory \"" + subCat.SubCategoryName + "\"?";
                    if (MessageBox.Show(prompt, "Confirm", MessageBoxButtons.OKCancel) != DialogResult.OK)
                    {
                        return;
                    }
                    onFirstRow = false;
                }
                else
                {
                    if (purLine.PurLine_VendorProductId.IsNull)
                    {
                        purLine.PurLine_ProductSubCategoryId = subCatId;
                        using (Ambient.DbSession.Activate())
                        {
                            OrderingRepositories.PurLine.Update(purLine.InnerPurLine);
                            numberSet++;
                        }
                    }
                    else
                    {
                        numberSkipped++;
                    }
                }
            }
            MessageBox.Show("Set subcategory for " + numberSet.ToString() + " rows.");
            MessageBox.Show("Skipped " + numberSkipped.ToString() + " rows because they were not manually added or imported to this order.");
            ShowLines();
            ShowTotalCost();
        }