Пример #1
0
        private void Butikkdata_Load(object sender, EventArgs e)
        {
            var mySql = new mySql();

            mySql.loadButikk(x);
            dataGridViewTest.DataSource = bindingSourceOrders;
            mySql.GetData(mySql.loadButikkStatement, bindingSourceOrders);
            for (int c = 0; c < dataGridViewTest.Columns.Count; ++c)
            {
                dataGridViewTest2.Columns.Add(dataGridViewTest.Columns[c].HeaderText, dataGridViewTest.Columns[c].HeaderText);
            }
            int Nindex = 0;

            for (int i = 0; i < dataGridViewTest.Rows.Count; i++)//each row
            {
                if (i < 1)
                {
                    dataGridViewTest2.Rows.Add();
                    for (int j = 0; j < dataGridViewTest.Columns.Count; ++j)//each cell in row
                    {
                        dataGridViewTest2.Rows[Nindex].Cells[j].Value = dataGridViewTest.Rows[i].Cells[j].Value;
                    }
                    Nindex++;
                }
                else
                {
                    if (dataGridViewTest.Rows[i].Cells["plu"].Value.ToString() == dataGridViewTest.Rows[i - 1].Cells["plu"].Value.ToString() & dataGridViewTest.Rows[i].Cells["farm"].Value.ToString() == dataGridViewTest.Rows[i - 1].Cells["farm"].Value.ToString())//if above is the same
                    {
                        dataGridViewTest2.Rows[Nindex - 1].Cells["stems"].Value   = Convert.ToInt32(dataGridViewTest2.Rows[Nindex - 1].Cells["stems"].Value) + Convert.ToInt32(dataGridViewTest.Rows[i].Cells["stems"].Value);
                        dataGridViewTest2.Rows[Nindex - 1].Cells["buckets"].Value = Convert.ToInt32(dataGridViewTest2.Rows[Nindex - 1].Cells["stems"].Value) / Convert.ToInt32(dataGridViewTest2.Rows[Nindex - 1].Cells["Stems pr bunch"].Value) / Convert.ToInt32(dataGridViewTest2.Rows[Nindex - 1].Cells["Bunch pr bucket"].Value);
                    }
                    else
                    {
                        dataGridViewTest2.Rows.Add();
                        for (int j = 0; j < dataGridViewTest.Columns.Count; ++j)//each cell in row
                        {
                            dataGridViewTest2.Rows[Nindex].Cells[j].Value = dataGridViewTest.Rows[i].Cells[j].Value;
                        }
                        Nindex++;
                    }
                }
            }
            dataGridViewTest2.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("arial", 7);
            dataGridViewTest2.Columns[0].Visible               = false;
            dataGridViewTest2.Columns[1].Visible               = false;
            dataGridViewTest2.Columns[2].Visible               = false;
            dataGridViewTest2.Columns[3].Visible               = false;
            dataGridViewTest2.Columns["variety"].Visible       = false;
            dataGridViewTest2.Columns["length"].Width          = 45;
            dataGridViewTest2.Columns["mix"].Width             = 45;
            dataGridViewTest2.Columns["sleeve"].Width          = 80;
            dataGridViewTest2.Columns["with sleeves"].Width    = 40;
            dataGridViewTest2.Columns["fairtrade"].Width       = 40;
            dataGridViewTest2.Columns["bunch pr bucket"].Width = 40;
            dataGridViewTest2.Columns["stems pr bunch"].Width  = 40;
            dataGridViewTest2.Columns["plu"].Width             = 50;
            //dataGridViewTest2.Columns["boxes"].Visible = false;
            dataGridViewTest2.Columns["stems"].Width = 45;
            //dataGridViewTest2.Columns["price"].Width = 45;
            dataGridViewTest2.Columns["buckets"].Width = 45;

            mySql.fillupLabelsButikk(lblOrdreNumber, lblDeparture, lblArrival, lblDatecode, lblAmountStems, lblAmountBuckets, dataGridViewTest2);
            lblOrderNumberTitle.Text = lblOrdreNumber.Text;
        }