Ejemplo n.º 1
0
        public void updateFarmsForm()
        {
            var mySql = new mySql();
            int y     = Convert.ToInt32(dataGridViewFarms.Rows[dataGridViewFarms.CurrentRow.Index].Cells[1].Value);

            mySql.loadOneFarm(x, y);
            dataGridViewFarmBestilling.DataSource = bindingSourceOrders2;
            mySql.GetData(mySql.farmsLoadOneFarmStatement, bindingSourceOrders2);
            lblOrdreNumber.Text = dataGridViewFarmBestilling.Rows[0].Cells["order_number"].Value.ToString();
            lblDeparture.Text   = dataGridViewFarmBestilling.Rows[0].Cells["departure"].Value.ToString().Substring(0, 10);;
            lblArrival.Text     = dataGridViewFarmBestilling.Rows[0].Cells["arrival"].Value.ToString().Substring(0, 10);;
            lblDatecode.Text    = dataGridViewFarmBestilling.Rows[0].Cells["datecode"].Value.ToString();
            int     sumBoxes = 0;
            decimal sumPrice = 0;

            for (int i = 0; i < dataGridViewFarmBestilling.Rows.Count; ++i)
            {
                sumBoxes += Convert.ToInt32(dataGridViewFarmBestilling.Rows[i].Cells["boxes"].Value);
                sumPrice += Convert.ToDecimal(dataGridViewFarmBestilling.Rows[i].Cells["price"].Value);
            }
            lblAmountPrice.Text = sumPrice.ToString();
            lblAmountBoxes.Text = sumBoxes.ToString();
            dataGridViewFarmBestilling.Columns["variety"].Width        = 200;
            dataGridViewFarmBestilling.Columns["order_number"].Visible = false;
            dataGridViewFarmBestilling.Columns["departure"].Visible    = false;
            dataGridViewFarmBestilling.Columns["arrival"].Visible      = false;
            dataGridViewFarmBestilling.Columns["datecode"].Visible     = false;
            dataGridViewFarmBestilling.Columns["farm"].Visible         = false;
            dataGridViewFarmBestilling.Columns["boxes"].DisplayIndex   = 16;
        }
Ejemplo n.º 2
0
        public string cbChange(ComboBox cb, string sqlStatement, Button b, DataGridView dg, string table)
        {
            var mySql = new mySql();

            if (cb.SelectedIndex == 0)
            {
                sqlStatement = " ";
                b.Visible    = false;
            }
            else
            {
                int selectedFarmId;
                foreach (DataGridViewRow row in dg.Rows)
                {
                    if (row.Cells[1].Value.ToString() == cb.SelectedItem.ToString())
                    {
                        selectedFarmId = Convert.ToInt32(row.Cells[0].Value);
                        sqlStatement   = table + selectedFarmId.ToString();
                        break;
                    }
                }
                b.Visible = true;
            }
            return(sqlStatement);
        }
Ejemplo n.º 3
0
        private void AddFl_Load(object sender, EventArgs e)
        {
            var mySql = new mySql();

            //fill up dataGridView by Farms
            dataGridView1.DataSource = bindingSource1;
            mySql.GetData(mySql.select, bindingSource1);
            //fill up dataGridView by Lengths
            dataGridView2.DataSource = bindingSource2;
            mySql.GetData(mySql.selectLengths, bindingSource2);
            ////fill up dataGridView by Colours
            dataGridView3.DataSource = bindingSource3;
            mySql.GetData(mySql.selectColour, bindingSource3);
            ////fill up dataGridView by Sleeves
            dataGridView4.DataSource = bindingSource4;
            mySql.GetData(mySql.selectSleeve, bindingSource4);


            //fill up combo boxes
            Sql = "SELECT farms.farm_name FROM[MG_inkjop].[dbo].[farms]";
            fillUpCb(cbFarm);
            Sql = "SELECT lengths.length FROM[MG_inkjop].[dbo].[lengths]";
            fillUpCb(cbLengths);
            Sql = "SELECT colours.colour FROM[MG_inkjop].[dbo].[colours]";
            fillUpCb(cbColour);
            Sql = "SELECT sleeves.sleeve FROM[MG_inkjop].[dbo].[sleeves]";
            fillUpCb(cbSleeve);
        }
Ejemplo n.º 4
0
 private void keypressed(Object o, KeyPressEventArgs e)//ENTER key
 {
     if (e.KeyChar == (char)Keys.Return)
     {
         e.Handled = true;
         if (string.IsNullOrWhiteSpace(txtSearch.Text))
         {
         }
         else
         {
             string tmp = txtSearch.Text;
             cbLengths.SelectedIndex = 0;
             cbColour.SelectedIndex  = 0;
             cbFarm.SelectedIndex    = 0;
             cbSleeve.SelectedIndex  = 0;
             radioButtonMix1.Checked = true;
             radioButtonFt1.Checked  = true;
             txtSearch.Text          = tmp;
             var    mySql  = new mySql();
             string search = "and flowers.plu=" + txtSearch.Text;
             CBselect = mySql.selectFlAddOr + search;
             mySql.GetData(CBselect, bindingSource1);
             mySql.updateAntall(lblAddOrAntalFl, dataGridViewOA);
         }
     }
 }
Ejemplo n.º 5
0
        private void Edit_FormClosing(object sender, FormClosingEventArgs e)
        {
            var mySql = new mySql();

            mySql.GetData(selectionStatement4, bindingSource1);
            label2.Text = dataGridViewFlMain.RowCount.ToString();//count amount of rows
        }
Ejemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)//save button
        {
            findComboValues();
            var    mySql = new mySql();
            string save2 = @" UPDATE[MG_inkjop].[dbo].[flowers]
                SET flowers.variety = '" + txtEVariety.Text + "'" +
                           ", flowers.colour_id = '" + newColourId + "'" +
                           ", flowers.plu = '" + txtEPlu.Text + "'" +
                           ", flowers.farm_id = '" + newFarmId + "'" +
                           ", flowers.mix = '" + newMix + "'" +
                           ", flowers.sticker_text = '" + txtESticker.Text + "'" +
                           ", flowers.length_id = '" + newLengthId + "'" +
                           ", flowers.sleeve_id = '" + newSleeveId + "'" +
                           ", flowers.fob = '" + fob + "'" +
                           ", flowers.fairtrade = '" + newFt + "'" +
                           ", flowers.sleeve_with = '" + newSleeve_with + "'" +
                           ", flowers.bunch_pr_bucket = '" + txtEBunchPBucket.Text + "'" +
                           ", flowers.stems_pr_bunch = '" + txtEStems.Text + "'" +
                           ", flowers.pak_rate = '" + txtEPak.Text + "'" +

                           "WHERE fl_id = " + label2.Text;

            mySql.GetData(save2, bindingSource1);
            this.Close();
        }
Ejemplo n.º 7
0
        private void Add_FormClosing(object sender, FormClosingEventArgs e)
        {
            var mySql = new mySql();

            mySql.GetData(selectionStatement4, bindingSource1);
            label2.Text = dataGridViewFlMain.RowCount.ToString();//count amount of rows
            dataGridViewFlMain.CurrentCell = dataGridViewFlMain.Rows[dataGridViewFlMain.RowCount - 1].Cells["plu"];
        }
Ejemplo n.º 8
0
 private void dataGridViewO1_SelectionChanged(object sender, EventArgs e)
 {
     if (loadOrders)
     {
         var mySql = new mySql();
         mySql.updateOrderInspecor(dataGridViewO1, dataGridViewO2, bindingSourceOrders2, lblDateCreated, lblDateModified, lblAmountBuckets, lblAmountPrice, lblAmountStems, lblAmountBoxes);
     }
 }
Ejemplo n.º 9
0
        private void cbSleeve_SelectedIndexChanged(object sender, EventArgs e)
        {
            var mySql = new mySql();

            whSleeve = mySql.findCbValue(cbSleeve, whSleeve, btnRemoveAOS, dataGridView4, "and sleeves.sleeve_id=", txtSearch);
            CBselect = mySql.selectFlAddOr + whFarm + whLen + whColour + whSleeve + whMix + whFt;
            mySql.GetData(CBselect, bindingSource1);
            mySql.updateAntall(lblAddOrAntalFl, dataGridViewOA);
        }
Ejemplo n.º 10
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //TODO: message about succesful edded flower and scrool to added row
            var mySql = new mySql();

            if (cheMix.Checked)
            {
                mix = "1";
            }
            if (cheFt.Checked)
            {
                ft = "1";
            }
            if (cheSleeveWith.Checked)
            {
                sleeveWith = "1";
            }

            string addFl = @" INSERT INTO[MG_inkjop].[dbo].[flowers]

           ([variety]
           ,[colour_id]
           ,[plu]
           ,[farm_id]
           ,[mix]
           ,[sticker_text]
           ,[length_id]
           ,[sleeve_id]
           ,[sleeve_with]
           ,[fob]
           ,[fairtrade]
           ,[bunch_pr_bucket]
           ,[stems_pr_bunch]
           ,[pak_rate])
     VALUES
           ('" + txtEVariety.Text + "'" +
                           ",'" + selectedColour + "'" +
                           ",'" + txtEPlu.Text + "'" +
                           ",'" + selectedFarmId + "'" +
                           ",'" + mix + "'" +
                           ",'" + txtESticker.Text + "'" +
                           ",'" + selectedLength + "'" +
                           ",'" + selectedSleeve + "'" +
                           ",'" + sleeveWith + "'" +
                           ",'" + txtEFob.Text + "'" +
                           ",'" + ft + "'" +
                           ",'" + txtEBunchPBucket.Text + "'" +
                           ",'" + txtEStems.Text + "'" +
                           ",'" + txtEPak.Text + "')";

            mySql.GetData(addFl, bindingSource1);
            string v = txtEVariety.Text;

            this.Close();
            MessageBox.Show("Blomst " + v + " har lagt til med hell", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Ejemplo n.º 11
0
        private void AddOr_FormClosing(object sender, FormClosingEventArgs e)
        {
            var mySql = new mySql();

            string Sql1 = " select distinct orders.order_number as 'Order number', departure as 'Departure', arrival as 'Arrival', datecode as 'Datecode' from orders";

            dataGridViewO1.DataSource = bindingSourceOrders;
            mySql.GetData(Sql1, bindingSourceOrders);
            mySql.updateOrderInspecor(dataGridViewO1, dataGridViewO2, bindingSourceOrders2, lblDateCreated, lblDateModified, lblAmountBuckets, lblAmountPrice, lblAmountStems, lblAmountBoxes);
        }
Ejemplo n.º 12
0
        // Flowers - LENGTH FILTER ///////////
        private void cbLength_SelectedIndexChanged(object sender, EventArgs e) // LENGTH FILTER ///////////
        {
            var CB = new CB();

            whLen = CB.cbChange(cbLength, whLen, btnRemoveFL, dataGridViewFL, "and flowers.length_id=");
            var mySql = new mySql();

            selectionStatement4 = mySql.FlowersMainStatement + whFarm + whLen;
            mySql.GetData(selectionStatement4, bindingSource1);
            label2.Text = dataGridViewFlMain.RowCount.ToString();//count amount of rows
            fillUpInspectorFl();
            setWidth(dataGridViewFlMain);
        }
Ejemplo n.º 13
0
        private void radioButtonFt3_CheckedChanged(object sender, EventArgs e)
        {
            var mySql = new mySql();

            if (radioButtonFt3.Checked)
            {
                whFt = "and flowers.fairtrade=0";
            }
            CBselect = mySql.selectFlAddOr + whFarm + whLen + whColour + whSleeve + whMix + whFt;
            mySql.GetData(CBselect, bindingSource1);
            txtSearch.Text = "";
            mySql.updateAntall(lblAddOrAntalFl, dataGridViewOA);
        }
Ejemplo n.º 14
0
        // DELETE Flower///////////////////////////////////////////////////////////////
        private void btnFDelete_Click(object sender, EventArgs e)
        {
            var          mySql        = new mySql();
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete " + dataGridViewFlMain[0, dataGridViewFlMain.CurrentRow.Index].Value.ToString() + " flower from database? This Action can not be undone", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);

            if (dialogResult == DialogResult.Yes)
            {
                var    idToDelete = dataGridViewFlMain[0, dataGridViewFlMain.CurrentRow.Index].Value.ToString();
                string delete     = @"DELETE FROM [dbo].[flowers] WHERE fl_id=" + idToDelete;
                mySql.GetData(delete, bindingSource1);
            }
            mySql.GetData(selectionStatement4, bindingSource1);
        }
Ejemplo n.º 15
0
        private void Farms_Load(object sender, EventArgs e)
        {
            lblOrderNumberTitle.Text = x.ToString();
            var mySql = new mySql();

            mySql.loadFarms(x);
            dataGridViewFarms.DataSource = bindingSourceOrders;
            mySql.GetData(mySql.farmsLoadFarmsStatement, bindingSourceOrders);
            dataGridViewFarms.Columns["farm_id"].Visible = false;
            dataGridViewFarms.Columns[0].Width           = 170;

            updateFarmsForm();
        }
Ejemplo n.º 16
0
        void addFlowerToOrder()
        {
            //TODO: check if fl_id is not exist in that order
            var mySql = new mySql();

            createSQLSelelct();
            createSQLInsert();
            mySql.GetData(insertFltoOrder, bindingSourceOrders);
            dataGridViewAON.DataSource = bindingSourceOrders;
            mySql.GetData(selectOrder, bindingSourceOrders);
            dataGridViewAON.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            lblAddOrAntallBoxes.Text      = mySql.sumColumn(dataGridViewAON, "boxes");
            lblAddOrAntallStems.Text      = mySql.sumColumn(dataGridViewAON, "stems");
            lblAddOrAntallPrice.Text      = mySql.sumColumn(dataGridViewAON, "price");
            lblAddOrAntallBuckets.Text    = mySql.sumColumn(dataGridViewAON, "buckets");
        }
Ejemplo n.º 17
0
        private void fillUpCb(ComboBox cb)
        {
            //fill up combo box by Farms
            var           mySql = new mySql();
            SqlConnection conn  = new SqlConnection(mySql.connString);

            conn.Open();
            SqlCommand    cmd = new SqlCommand(Sql, conn);
            SqlDataReader DR  = cmd.ExecuteReader();

            while (DR.Read())
            {
                cb.Items.Add(DR[0]);
            }
            cb.SelectedIndex = 0;
            conn.Close();
        }
Ejemplo n.º 18
0
        private void Avvik_Load(object sender, EventArgs e)
        {
            lblOrderNumberTitle.Text = x.ToString();
            var mySql = new mySql();

            mySql.loadAvvik(x);
            dataGridViewTest.DataSource = bindingSourceOrders;
            mySql.GetData(mySql.loadAvvikStatement, bindingSourceOrders);

            dataGridViewTest.Columns[0].Visible            = false;
            dataGridViewTest.Columns[1].Visible            = false;
            dataGridViewTest.Columns[2].Visible            = false;
            dataGridViewTest.Columns[3].Visible            = false;
            dataGridViewTest.Columns["variety"].Width      = 200;
            dataGridViewTest.Columns["boxes"].DisplayIndex = 15;
            mySql.fillupLabelsAvvik(lblOrdreNumber, lblDeparture, lblArrival, lblDatecode, lblAmountBoxes, dataGridViewTest);
        }
Ejemplo n.º 19
0
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (tabControl1.SelectedIndex == 1)
            {
                var mySql = new mySql();

                string Sql1 = " select distinct orders.order_number as 'Order number', departure as 'Departure', arrival as 'Arrival', datecode as 'Datecode' from orders";
                dataGridViewO1.DataSource = bindingSourceOrders;
                mySql.GetData(Sql1, bindingSourceOrders);
                mySql.updateOrderInspecor(dataGridViewO1, dataGridViewO2, bindingSourceOrders2, lblDateCreated, lblDateModified, lblAmountBuckets, lblAmountPrice, lblAmountStems, lblAmountBoxes);

                dataGridViewO1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                dataGridViewO2.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                //dataGridViewO1.Rows[0].Selected = () ? false : true;
                setWidth(dataGridViewO1);
                loadOrders = true;
            }
        }
Ejemplo n.º 20
0
 private void btnSearchFl_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrWhiteSpace(txtSearch.Text))
     {
     }
     else
     {
         string tmp = txtSearch.Text;
         cbLengths.SelectedIndex = 0;
         cbColour.SelectedIndex  = 0;
         cbFarm.SelectedIndex    = 0;
         cbSleeve.SelectedIndex  = 0;
         radioButtonMix1.Checked = true;
         radioButtonFt1.Checked  = true;
         txtSearch.Text          = tmp;
         var    mySql  = new mySql();
         string search = "and flowers.plu=" + txtSearch.Text;
         CBselect = mySql.selectFlAddOr + search;
         mySql.GetData(CBselect, bindingSource1);
         mySql.updateAntall(lblAddOrAntalFl, dataGridViewOA);
     }
 }
Ejemplo n.º 21
0
        private void AddOr_Load(object sender, EventArgs e)
        {
            var mySql = new mySql();

            CBselect = mySql.selectFlAddOr + whFarm + whLen + whColour + whSleeve + whMix + whFt;
            dataGridViewOA.DataSource = bindingSource1;
            mySql.GetData(CBselect, bindingSource1);
            dataGridViewOA.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            //fill up dataGridView by Farms
            dataGridView1.DataSource = bindingSource5;
            mySql.GetData(mySql.selectFarms, bindingSource5);
            //fill up dataGridView by Lengths
            dataGridView2.DataSource = bindingSource2;
            mySql.GetData(mySql.selectLengths, bindingSource2);
            ////fill up dataGridView by Colours
            dataGridView3.DataSource = bindingSource3;
            mySql.GetData(mySql.selectColour, bindingSource3);
            ////fill up dataGridView by Sleeves
            dataGridView4.DataSource = bindingSource4;
            mySql.GetData(mySql.selectSleeve, bindingSource4);
            //fill up combo boxes
            mySql.fillUpCb(cbFarm, "SELECT farms.farm_name FROM[MG_inkjop].[dbo].[farms]");
            mySql.fillUpCb(cbLengths, "SELECT lengths.length FROM[MG_inkjop].[dbo].[lengths]");
            mySql.fillUpCb(cbColour, "SELECT colours.colour FROM[MG_inkjop].[dbo].[colours]");
            mySql.fillUpCb(cbSleeve, "SELECT sleeves.sleeve FROM[MG_inkjop].[dbo].[sleeves]");
            dataGridViewOA.Columns[0].Visible = true;

            dataGridViewOrders.DataSource = bindingSourceOrders;
            mySql.GetData("select order_number from [MG_inkjop].[dbo].[orders] group by order_number", bindingSourceOrders);
            dataGridViewOrders.AllowUserToAddRows = false;//prevent from create empt row on the end

            tabControlAddOrder.Appearance = TabAppearance.Buttons;
            tabControlAddOrder.ItemSize   = new Size(0, 1);
            tabControlAddOrder.SizeMode   = TabSizeMode.Fixed;

            radioButtonMix1.Checked = true;
            radioButtonFt1.Checked  = true;
            mySql.updateAntall(lblAddOrAntalFl, dataGridViewOA);
        }
Ejemplo n.º 22
0
 public void fillUpInspectorFl()
 {
     if (dataGridViewFlMain.Rows.Count > 1)
     {
         int    row   = dataGridViewFlMain.CurrentCell.RowIndex;
         var    mySql = new mySql();
         int    fl_id = Convert.ToInt32(dataGridViewFlMain.Rows[row].Cells[0].Value);
         string loadOrdersStatement2 = @"
         SELECT top 1
             orders.order_id
             ,orders.departure
             ,orders.order_number
             ,orders.arrival
             ,orders.boxes
           FROM[MG_inkjop].[dbo].[flowers], [MG_inkjop].[dbo].[farms], [MG_inkjop].[dbo].[lengths], [MG_inkjop].[dbo].[colours], [MG_inkjop].[dbo].[sleeves], [MG_inkjop].[dbo].[orders]
           WHERE flowers.farm_id = farms.farm_id and flowers.length_id = lengths.length_id and flowers.colour_id = colours.colour_id and flowers.sleeve_id = sleeves.sleeve_id and flowers.fl_id = orders.fl_id and orders.fl_id = " + fl_id + "  ORDER BY arrival desc";
         dataGridViewFlOr.DataSource = bindingSourceOrders3;
         mySql.GetData(loadOrdersStatement2, bindingSourceOrders3);
         lblInsFob.Text         = dataGridViewFlMain.Rows[row].Cells["Fob"].Value.ToString();
         lblInsSticker.Text     = dataGridViewFlMain.Rows[row].Cells["Sticker text"].Value.ToString();
         lblInsSleeve.Text      = dataGridViewFlMain.Rows[row].Cells["Sleeve"].Value.ToString();
         cheInsWtSleeve.Checked = (dataGridViewFlMain.Rows[row].Cells["With sleeves"].Value.ToString() == "True") ? true : false;
         cheInsMix.Checked      = (dataGridViewFlMain.Rows[row].Cells["mix"].Value.ToString() == "True") ? true : false;
         lblInsSisteOr.Text     = (dataGridViewFlOr.Rows.Count < 2) ? "aldri" : dataGridViewFlOr.Rows[0].Cells["order_number"].Value.ToString();
         lblInsBoxes.Text       = (dataGridViewFlOr.Rows.Count < 2) ? "aldri" : dataGridViewFlOr.Rows[0].Cells["boxes"].Value.ToString();
     }
     else
     {
         lblInsFob.Text         = "-";
         lblInsSticker.Text     = "-";
         lblInsSleeve.Text      = "-";
         cheInsWtSleeve.Checked = false;
         cheInsMix.Checked      = false;
         lblInsSisteOr.Text     = "-";
         lblInsBoxes.Text       = "-";
     }
 }
Ejemplo n.º 23
0
        private void Form1_Load(object sender, EventArgs e)
        {
            var mySql = new mySql();
            var menu  = new Design();

            menu.resBtn(button1, button2, button3, button4, menuArrow1, menuArrow2, menuArrow3, menuArrow4);
            Color _selected = System.Drawing.ColorTranslator.FromHtml("#243240");

            button1.BackColor         = _selected;
            menuArrow1.Visible        = true;
            dataGridViewFL.DataSource = bindingSource3;
            mySql.GetData(mySql.loadLengthsStatement, bindingSource3);
            dataGridViewFF.DataSource = bindingSourceFarms;
            mySql.GetData(mySql.loadFarmsStatement, bindingSourceFarms);


            dataGridViewFlMain.DataSource = bindingSource1;
            mySql.GetData(mySql.FlowersMainStatement, bindingSource1);

            dataGridViewFlMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect;



            dataGridViewFlMain.Columns["fl_id"].Visible = false;
            dataGridViewFlMain.Columns["Variety"].Width = 100;

            dataGridViewFlMain.Columns["Sticker text"].Visible = false;
            dataGridViewFlMain.Columns["Colour"].Width         = 60;
            dataGridViewFlMain.Columns["PLU"].Width            = 40;
            dataGridViewFlMain.Columns["Farm"].Width           = 40;
            dataGridViewFlMain.Columns["mix"].Visible          = false;
            dataGridViewFlMain.Columns["Sleeve"].Visible       = false;
            dataGridViewFlMain.Columns["With sleeves"].Visible = false;
            dataGridViewFlMain.Columns["fob"].Visible          = false;
            int s = 41;

            dataGridViewFlMain.Columns["Fairtrade"].Width       = s;
            dataGridViewFlMain.Columns["Bunch_pr bucket"].Width = s;
            dataGridViewFlMain.Columns["Stems_pr bunch"].Width  = s;
            dataGridViewFlMain.Columns["pak rate"].Width        = 48;



            tabControl1.Appearance = TabAppearance.Buttons;
            tabControl1.ItemSize   = new Size(0, 1);
            tabControl1.SizeMode   = TabSizeMode.Fixed;
            //////////////// fil up comboBox
            string        Sql  = "SELECT farms.farm_name FROM[MG_inkjop].[dbo].[farms]";
            SqlConnection conn = new SqlConnection(mySql.connString);

            conn.Open();
            SqlCommand    cmd = new SqlCommand(Sql, conn);
            SqlDataReader DR  = cmd.ExecuteReader();

            cbFarm.Items.Add("All");
            while (DR.Read())
            {
                cbFarm.Items.Add(DR[0]);
            }
            cbFarm.SelectedIndex = 0;
            conn.Close();
            //////////////// fil up comboBox
            string Sql2 = "SELECT lengths.length FROM[MG_inkjop].[dbo].[lengths]";

            conn.Open();
            SqlCommand    cmd2 = new SqlCommand(Sql2, conn);
            SqlDataReader DR2  = cmd2.ExecuteReader();

            cbLength.Items.Add("All");
            while (DR2.Read())
            {
                cbLength.Items.Add(DR2[0]);
            }
            cbLength.SelectedIndex = 0;
            conn.Close();
            label2.Text = dataGridViewFlMain.RowCount.ToString();//count amount of rows



            fillUpInspectorFl();

            loaded = true;
        }
Ejemplo n.º 24
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;
        }
Ejemplo n.º 25
0
        private void EditFl_Load(object sender, EventArgs e)
        {
            var mySql = new mySql();

            dataGridView2.DataSource = bindingSource2; //fill up lengths table
            mySql.GetData(selectLengths, bindingSource2);
            dataGridView3.DataSource = bindingSource3; //fill up colours table
            mySql.GetData(selectColours, bindingSource3);
            dataGridView4.DataSource = bindingSource5; //fill up farms table
            mySql.GetData(selectFarms, bindingSource5);
            dataGridView5.DataSource = bindingSource4; //fill up sleeves table
            mySql.GetData(selectSleeves, bindingSource4);

            //fill up combo boxes
            Sql = "SELECT farms.farm_name FROM[MG_inkjop].[dbo].[farms]";
            fillUpCb(cbFarm);
            Sql = "SELECT lengths.length FROM[MG_inkjop].[dbo].[lengths]";
            fillUpCb(cbLengths);
            Sql = "SELECT colours.colour FROM[MG_inkjop].[dbo].[colours]";
            fillUpCb(cbColour);
            Sql = "SELECT sleeves.sleeve FROM[MG_inkjop].[dbo].[sleeves]";
            fillUpCb(cbSleeve);

            int idToEdit2 = Form1.idToEdit;

            label2.Text = idToEdit2.ToString();
            dataGridView1.DataSource = bindingSource1;
            mySql.GetData(selectionStatement3, bindingSource1);
            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                //MessageBox.Show(row.Cells[0].Value.ToString());
                if (row.Cells[0].Value.ToString() == idToEdit2.ToString())
                {
                    rowIndex = row.Index;
                    break;
                }
            }
            cbColour.Text  = dataGridView1["colour", rowIndex].Value.ToString();
            cbFarm.Text    = dataGridView1["farm_name", rowIndex].Value.ToString();
            cbLengths.Text = dataGridView1["length", rowIndex].Value.ToString();
            cbSleeve.Text  = dataGridView1["sleeve", rowIndex].Value.ToString();
            //findCbIndex(cbColour, "colour");//check and set proper item in combobox
            //cbColour.SelectedIndex = fci;
            //findCbIndex(cbFarm, "farm");//check and set proper item in combobox
            //cbFarm.SelectedIndex = fci;
            //findCbIndex(cbLengths, "length");//check and set proper item in combobox
            //cbLengths.SelectedIndex = fci;
            //findCbIndex(cbSleeve, "sleeve");//check and set proper item in combobox
            //cbSleeve.SelectedIndex = fci;

            txtEVariety.Text      = dataGridView1["variety", rowIndex].Value.ToString();
            txtEPlu.Text          = dataGridView1["plu", rowIndex].Value.ToString();
            txtESticker.Text      = dataGridView1["sticker_text", rowIndex].Value.ToString();
            txtEFob.Text          = dataGridView1["fob", rowIndex].Value.ToString();
            txtEBunchPBucket.Text = dataGridView1["bunch_pr_bucket", rowIndex].Value.ToString();
            txtEStems.Text        = dataGridView1["stems_pr_bunch", rowIndex].Value.ToString();
            txtEPak.Text          = dataGridView1["pak_rate", rowIndex].Value.ToString();
            if (dataGridView1["mix", rowIndex].Value.ToString() == "True")
            {
                cheMix.Checked = true;                                                            // check and set "mix" checkbox
            }
            else
            {
                cheMix.Checked = false;
            }
            if (dataGridView1["fairtrade", rowIndex].Value.ToString() == "True")
            {
                cheFt.Checked = true;                                                                  // check and set "fairtrade" checkbox
            }
            else
            {
                cheFt.Checked = false;
            }
            if (dataGridView1["sleeve_with", rowIndex].Value.ToString() == "True")
            {
                cheSleeveWith.Checked = true;                                                                    // check and set "fairtrade" checkbox
            }
            else
            {
                cheSleeveWith.Checked = false;
            }
        }