Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            GOOD_FOODDataSet dataB = parent.getDataBase();

            GOOD_FOODDataSet.ComenziRow crow = dataB.Comenzi.NewComenziRow();
            crow.id_client    = IDClient;
            crow.data_comanda = new DateTime();
            GOOD_FOODDataSet.SubcomenziRow scrow;
            foreach (DataGridViewRow r in Comanda_DataGridView.Rows)
            {
                int cantitate = 1;
                int IDProdus  = 0;
                foreach (DataGridViewCell cell in r.Cells)
                {
                    if (r.Cells.IndexOf(cell) == 0)
                    {
                        foreach (GOOD_FOODDataSet.MeniuRow mr in dataB.Meniu)
                        {
                            if (mr.denumire_produs == cell.Value)
                            {
                                IDProdus = mr.id_produs;
                            }
                        }
                    }
                    else if (r.Cells.IndexOf(cell) == 3)
                    {
                        cantitate = Convert.ToInt32(cell.Value.ToString());
                    }
                }
                scrow            = dataB.Subcomenzi.NewSubcomenziRow();
                scrow.cantitate  = cantitate;
                scrow.id_produs  = IDProdus;
                scrow.id_comanda = crow.id_comanda;
                dataB.Subcomenzi.Rows.Add(scrow);
            }
            dataB.Comenzi.Rows.Add(crow);
            parent.updateDataBase();
            MessageBox.Show("Comanda trimisa!");
            this.Close();
        }
Exemplo n.º 2
0
 private void GenMeniu_GridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 5)
     {
         DataGridViewRow row = null;
         foreach (DataGridViewRow r in GenMeniu_GridView.Rows)
         {
             if (GenMeniu_GridView.Rows.IndexOf(r) == e.RowIndex)
             {
                 row = r;
                 break;
             }
         }
         String fel1 = "";
         String fel2 = "";
         String fel3 = "";
         foreach (DataGridViewCell cell in row.Cells)
         {
             if (row.Cells.IndexOf(cell) == 0)
             {
                 fel1 = cell.Value.ToString();
             }
             else if (row.Cells.IndexOf(cell) == 1)
             {
                 fel2 = cell.Value.ToString();
             }
             else if (row.Cells.IndexOf(cell) == 2)
             {
                 fel3 = cell.Value.ToString();
             }
         }
         int idProd1            = 1;
         int idProd2            = 2;
         int idProd3            = 3;
         GOOD_FOODDataSet dataB = parent.getDataBase();
         foreach (GOOD_FOODDataSet.MeniuRow mr in dataB.Meniu)
         {
             if (mr.denumire_produs == fel1)
             {
                 idProd1 = mr.id_produs;
             }
             if (mr.denumire_produs == fel2)
             {
                 idProd2 = mr.id_produs;
             }
             if (mr.denumire_produs == fel3)
             {
                 idProd3 = mr.id_produs;
             }
         }
         GOOD_FOODDataSet.ComenziRow crow = dataB.Comenzi.NewComenziRow();
         crow.id_client    = userID;
         crow.data_comanda = new DateTime();
         GOOD_FOODDataSet.SubcomenziRow scrow = dataB.Subcomenzi.NewSubcomenziRow();
         scrow.cantitate  = 1;
         scrow.id_produs  = idProd1;
         scrow.id_comanda = crow.id_comanda;
         dataB.Subcomenzi.Rows.Add(scrow);
         scrow            = dataB.Subcomenzi.NewSubcomenziRow();
         scrow.cantitate  = 1;
         scrow.id_produs  = idProd2;
         scrow.id_comanda = crow.id_comanda;
         dataB.Subcomenzi.Rows.Add(scrow);
         scrow            = dataB.Subcomenzi.NewSubcomenziRow();
         scrow.cantitate  = 1;
         scrow.id_produs  = idProd3;
         scrow.id_comanda = crow.id_comanda;
         dataB.Subcomenzi.Rows.Add(scrow);
         dataB.Comenzi.Rows.Add(crow);
         parent.updateDataBase();
         MessageBox.Show("Comanda trimisa!");
         this.Close();
     }
 }