Ejemplo n.º 1
0
        private void AddColumnsToDataGridView(string tbname)
        {
            var reader = servConn.SelectAll(tbname);

            for (var k = 0; k < reader.FieldCount; k++)
            {
                DB_Table.Columns.Add(reader.GetName(k), reader.GetName(k));
            }
        }
Ejemplo n.º 2
0
        private void Buy_Load(object sender, EventArgs e)
        {
            var count_goods = servConn.CountRows(tableName);

            container = new Container[count_goods];

            var readerImages = servConn.SelectAll("FV_Product");

            var reader = servConn.SelectAll(tableName);
            int i      = 0;

            while (reader.Read() /*&& readerImages.Read()*/)
            {
                // var imagePath = readerImages.GetString(1);
                container[i].Shell = new Panel()
                {
                    Parent = Panel_Board, Location = new Point(i == 0 ? 15:  container[i - 1].Shell.Location.X + container[i - 1].Shell.Size.Width + 15, 17), Name = "Goods_" + i.ToString(), Size = new Size(200, 100), BorderStyle = BorderStyle.FixedSingle
                };

                container[i].Name = new Label()
                {
                    Parent = container[i].Shell, Location = new Point(10, 10), Size = new Size(185, 23), Name = "Name", Font = new Font("Microsoft Sans Serif", 14), Text = reader.GetString(1)
                };
                container[i].Price = new Label()
                {
                    Parent = container[i].Shell, Location = new Point(10, 40), Size = new Size(185, 16), Name = "Price_" + i.ToString(), Font = new Font("Microsoft Sans Serif", 12), Text = reader.GetValue(3).ToString() + "$", AutoSize = true
                };
                container[i].Description = new Label()
                {
                    Parent = container[i].Shell, Location = new Point(10, 70), Size = new Size(184, 64), Name = "Descr_" + i.ToString(), Font = new Font("Microsoft Sans Serif", 11), Text = reader.GetString(4)
                };
                container[i].Picture = new PictureBox()
                {
                    Parent = container[i].Shell, Location = new Point(14, 14), Name = "Picture_" + i.ToString(), Size = new Size(200, 100), BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage, Cursor = Cursors.Hand
                };
                container[i].Picture.Click += Furniture_Click;
                i++;
            }
        }
Ejemplo n.º 3
0
        public static void FillDataGridView(SQLServerConnect servConn, DataGridView dgw, string tableName)
        {
            dgw.Rows.Clear();
            dgw.Columns.Clear();

            int  count  = servConn.CountRows(tableName);
            bool create = true;
            var  reader = servConn.SelectAll(tableName);

            if (count == 0)
            {
                for (var k = 0; k < reader.FieldCount; k++)
                {
                    dgw.Columns.Add(reader.GetName(k), reader.GetName(k));
                }
            }

            for (var i = 0; i < count; i++)
            {
                reader.Read();
                if (create)
                {
                    for (var k = 0; k < reader.FieldCount; k++)
                    {
                        dgw.Columns.Add(reader.GetName(k), reader.GetName(k));
                    }
                    create = false;
                }
                dgw.Rows.Add();
                for (var j = 0; j < reader.FieldCount; j++)
                {
                    dgw.Rows[i].Cells[j].Value  = reader.GetValue(j);
                    dgw.Columns[j].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
                }
            }
        }