Exemple #1
0
 public void registrarLab(ELaboratorio lab)
 {
     if (validarLaboratorio(lab))
     {
         _laboratorio.insertar(lab);
     }
 }
Exemple #2
0
        private bool validarLaboratorio(ELaboratorio lab)
        {
            stringBuilder.Clear();


            if (string.IsNullOrEmpty(lab.nombre))
            {
                stringBuilder.Append(Environment.NewLine + "El campo Nombre es obligatorio");
            }


            //if (producto.Precio <= 0) stringBuilder.Append(Environment.NewLine + "El campo Precio es obligatorio");

            return(stringBuilder.Length == 0);
        }
Exemple #3
0
 public void insertar(ELaboratorio lab)
 {
     try
     {
         con.ConnectionString = Conexion.cn;
         con.Open();
         MySqlCommand cmd = con.CreateCommand();
         cmd.CommandText = "INSERT INTO laboratorio (laboratorio) value (@param1)";
         cmd.Parameters.AddWithValue("@param1", lab.nombre);
         cmd.ExecuteNonQuery();
         con.Close();
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
 }
Exemple #4
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     //int codigo = 1;
     try
     {
         if (this.txtLaboratorio.Text == string.Empty)
         {
             MensajeError("Falta ingresar algunos datos");
             //ErrorIcono.SetError(txtNombre, "Ingrese un Nombre de Laboratorio");
         }
         else
         {
             if (this.IsNuevo)
             {
                 elaboratorio        = new ELaboratorio();
                 elaboratorio.codigo = txtCodigo.Text.ToUpper();
                 elaboratorio.nombre = txtLaboratorio.Text.ToUpper();
                 productoLog.registrarLab(elaboratorio);
                 MessageBox.Show("Laboratorio registrado/actualizado con éxito");
             }
             else
             {
                 productoLog.editarLaboratorio(txtCodigo.Text, txtLaboratorio.Text.Trim().ToUpper());
                 MessageBox.Show("Producto actualizado con éxito");
             }
         }
         this.IsNuevo  = false;
         this.IsEditar = false;
         this.Botones();
         this.Limpiar();
         //this.Mostrar(centro);
         //this.ProximoVencer(centro);
         //this.tabControl1.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }