Beispiel #1
0
 private void BtnRegistrar_Click(object sender, EventArgs e)
 {
     if (txtCArroz.Text.Length > 0 && txtCFrijol.Text.Length > 0 && txtCLeche.Text.Length > 0 && txtCAceite.Text.Length > 0 && txtCBebida.Text.Length > 0)
     {
         if (txtFarroz.Text.Length > 0 && txtFfrijol.Text.Length > 0 && txtFaceite.Text.Length > 0 && txtFleche.Text.Length > 0 && txtFbebida.Text.Length > 0)
         {
             if (h.ExitsFecha(txtFarroz.Text) && h.DateMaxNow(txtFarroz.Text))
             {
                 if (h.ExitsFecha(txtFfrijol.Text) && h.DateMaxNow(txtFfrijol.Text))
                 {
                     if (h.ExitsFecha(txtFaceite.Text) && h.DateMaxNow(txtFaceite.Text))
                     {
                         if (h.ExitsFecha(txtFleche.Text) && h.DateMaxNow(txtFleche.Text))
                         {
                             if (h.ExitsFecha(txtFbebida.Text) && h.DateMaxNow(txtFbebida.Text))
                             {
                                 Consultas cons = new Consultas();
                                 List <Datos.Inventario> ListInventario = new List <Datos.Inventario>();
                                 int v = cons.GetLastIDInv();
                                 FechaActual = Convert.ToDateTime(DateTime.Now).ToString("dd/MM/yyyy");
                                 int bandera             = 4;
                                 int d                   = 0;
                                 Datos.Inventario invent = null;
                                 foreach (Control item in alimentospanel.Controls)
                                 {
                                     if (d == 0)
                                     {
                                         invent = new Datos.Inventario();
                                         invent.Id_inventario = v;
                                         invent.Id_alimento   = bandera;
                                         invent.Fecha_ingreso = FechaActual;
                                         bandera--;
                                         v++;
                                         invent.Fecha_vencimiento = item.Text;
                                         d++;
                                     }
                                     else
                                     {
                                         invent.Cantidad = Convert.ToInt32(item.Text);
                                         ListInventario.Add(invent);
                                         d = 0;
                                     }
                                 }
                                 //probar(ListInventario);
                                 cons.AddInventario(ListInventario);
                                 Limpiar();
                             }
                             else
                             {
                                 MessageBox.Show("Fecha Vencimiento de Bebida invalida", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                             }
                         }
                         else
                         {
                             MessageBox.Show("Fecha Vencimiento de Leche invalida", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                         }
                     }
                     else
                     {
                         MessageBox.Show("Fecha Vencimiento de Aceite invalida", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Fecha Vencimiento de Frijol invalida", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 MessageBox.Show("Fecha Vencimiento de Arroz invalida", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("Tiene que llenar todos los campos de Fecha", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Tiene que llenar todos los campos de Cantidad", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }