Esempio n. 1
0
        private void PopulateComboBoxes()
        {
            ProductCategory cat = new ProductCategory();

            try
            {
                //Product category
                DataSet   ds = cat.GetAllProductCategoryDataSet();
                DataTable dt = ds.Tables[0];
                DataRow   dr = dt.NewRow();
                dr["ProductCategoryID"] = 0;
                dr["Name"] = "<Select One>";
                dt.Rows.InsertAt(dr, 0);
                cmbProductCategory.DataSource    = dt;
                cmbProductCategory.DisplayMember = "Name";
                cmbProductCategory.ValueMember   = "ProductCategoryID";

                //Discount type (P: percentage, V:value)
                string[,] strDiscArray = { { "0", "<Select One>" }, { "P", "Percentage" }, { "V", "Value" } };
                dt = new DataTable();
                dt.Columns.Add(new DataColumn("ID", typeof(String)));
                dt.Columns.Add(new DataColumn("Desc", typeof(String)));
                for (int i = 0; i <= strDiscArray.Length / 3; i++)
                {
                    dr         = dt.NewRow();
                    dr["ID"]   = strDiscArray[i, 0];
                    dr["Desc"] = strDiscArray[i, 1];
                    dt.Rows.Add(dr);
                }
                cmbDiscountType.DataSource    = dt;
                cmbDiscountType.DisplayMember = "Desc";
                cmbDiscountType.ValueMember   = "ID";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "MICS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                cat = null;
            }
        }