示例#1
0
文件: AddGood.cs 项目: B10S2/Shop
        private void tabConstr()
        {
            DataGridViewCell   celInt = new DataGridViewTextBoxCell();
            DataGridViewColumn dc     = new DataGridViewColumn(celInt);

            dc.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            //Добавление ComboBoxColumn в DataGridView
            DataGridViewComboBoxColumn dc1 = new DataGridViewComboBoxColumn();

            dc1.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            string[] cat = null;
            try
            {
                cat            = Shop.GetCategoryes();
                dc1.DataSource = cat;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            DataGridViewColumn dc2 = new DataGridViewColumn(celInt);

            dc2.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            DataGridViewColumn dc3 = new DataGridViewColumn(celInt);

            dc3.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            dgv.Columns.Add(dc);
            dgv.Columns.Add(dc1);
            dgv.Columns.Add(dc2);
            dgv.Columns.Add(dc3);

            dgv.Columns[0].ValueType  = typeof(string);
            dgv.Columns[0].HeaderText = "штрих код";
            dgv.Columns[1].ValueType  = typeof(string);
            dgv.Columns[1].HeaderText = "категория";
            dgv.Columns[2].ValueType  = typeof(string);
            dgv.Columns[2].HeaderText = "название";
            dgv.Columns[3].ValueType  = typeof(string);
            dgv.Columns[3].HeaderText = "цена на продажу";
            dgv.Dock = DockStyle.Fill;
            dgv.AllowUserToAddRows     = false;
            dgv.RowCount               = 1;
            dgv.Rows[0].Cells[0].Value = this.Barcode;
            this.Controls.Add(dgv);
            dgv.RowsAdded += dgv_RowsAdded;
            //dgv.Rows[0].Cells[0].Value = bar;
        }
示例#2
0
文件: Form1.cs 项目: B10S2/Shop
        //Обновление информации в TabPages
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TabControl control = (sender as TabControl);

            if (control.SelectedTab.Text == "Все категории")
            {
                string[] Cat = Shop.GetCategoryes();
                dataGridView3.Rows.Clear();
                foreach (string s in Cat)
                {
                    DataGridViewRow  row = new DataGridViewRow();
                    DataGridViewCell cel = new DataGridViewTextBoxCell();
                    cel.Value = s;
                    row.Cells.Add(cel);
                    dataGridView3.Rows.Add(row);
                }
            }
            else if (control.SelectedTab.Text == "Все товары")
            {
                Good[] goods = Shop.GetAllGoods();
                dgvAllGoods.Rows.Clear();
                foreach (Good g in goods)
                {
                    DataGridViewRow  row = new DataGridViewRow();
                    DataGridViewCell cel = new DataGridViewTextBoxCell();
                    cel.Value = g.Barcode;
                    row.Cells.Add(cel);

                    cel       = new DataGridViewTextBoxCell();
                    cel.Value = g.Name;
                    row.Cells.Add(cel);

                    dgvAllGoods.Rows.Add(row);
                }
            }
            else if (control.SelectedTab.Text == "Товаров на складе")
            {
                Good[] goods = Shop.GetGoodsBalance();
                dgvBalance.Rows.Clear();
                foreach (Good g in goods)
                {
                    DataGridViewRow  row = new DataGridViewRow();
                    DataGridViewCell cel = new DataGridViewTextBoxCell();
                    cel.Value = g.Barcode;
                    row.Cells.Add(cel);

                    cel       = new DataGridViewTextBoxCell();
                    cel.Value = g.Name;
                    row.Cells.Add(cel);


                    cel       = new DataGridViewTextBoxCell();
                    cel.Value = g.Category;
                    row.Cells.Add(cel);


                    cel       = new DataGridViewTextBoxCell();
                    cel.Value = g.Count;
                    row.Cells.Add(cel);


                    cel       = new DataGridViewTextBoxCell();
                    cel.Value = g.PriceOut;
                    row.Cells.Add(cel);

                    dgvBalance.Rows.Add(row);
                }
            }
            else if (control.SelectedTab.Text == "Добавленные сегодня")
            {
                Good[] goods = Shop.GetGoodsToDay();
                dgvChangeInserted.Rows.Clear();
                foreach (Good g in goods)
                {
                    DataGridViewRow  row = new DataGridViewRow();
                    DataGridViewCell cel = new DataGridViewTextBoxCell();
                    cel.Value = g.Barcode;
                    row.Cells.Add(cel);

                    cel       = new DataGridViewTextBoxCell();
                    cel.Value = g.Name;
                    row.Cells.Add(cel);


                    cel       = new DataGridViewTextBoxCell();
                    cel.Value = g.Category;
                    row.Cells.Add(cel);


                    cel       = new DataGridViewTextBoxCell();
                    cel.Value = g.Count;
                    row.Cells.Add(cel);


                    cel       = new DataGridViewTextBoxCell();
                    cel.Value = g.PriceIn;
                    row.Cells.Add(cel);
                    row.Tag = g.idWare;

                    dgvChangeInserted.Rows.Add(row);
                }
            }
        }