Exemple #1
0
 public Produccion_Dañada BuscarPorId(string id)
 {
     try
     {
         Produccion_Dañada dato = new Produccion_Dañada();
         db.Conectar();
         SqlDataReader dr = (SqlDataReader)db.Consulta("SELECT * FROM produccion_dañada WHERE id=" + Convert.ToInt32(id));
         while (dr.Read())
         {
             for (int i = 0; i < 2; i++)
             {
                 dato.id         = Convert.ToInt32(dr[0].ToString());
                 dato.fecha      = Convert.ToDateTime(dr[1].ToString());
                 dato.nombre_emp = dr[2].ToString();
                 dato.id_prod    = Convert.ToInt32(dr[3].ToString());
                 dato.cantidad   = Convert.ToInt32(dr[4].ToString());
             }
         }
         db.Desconectar();
         Error = "";
         return(dato);
     }
     catch (Exception ex)
     {
         Error = ex.Message;
         return(null);
     }
 }
 private void btnAceptar_Click(object sender, RoutedEventArgs e)
 {
     if (producto != null)
     {
         if (txtCantidad.Text != "")
         {
             if (chkDañado.IsChecked == true)
             {
                 Produccion_Dañada produccion_dañada = new Produccion_Dañada()
                 {
                     id_prod    = producto.id,
                     nombre_emp = cboNombreEmp.SelectedItem.ToString(),
                     fecha      = fecha.DisplayDate,
                     cantidad   = Convert.ToInt16(txtCantidad.Text)
                 };
                 if (proddañadaManager.crear(produccion_dañada))
                 {
                     MessageBox.Show("Registrado");
                     CancelarTodo();
                 }
                 else
                 {
                     MessageBox.Show("Ha ocurrido un error " + proddañadaManager.Error.ToLower());
                 }
             }
             else if (chkPerdido.IsChecked == true)
             {
                 Producto_Perdido producto_perdido = new Producto_Perdido()
                 {
                     cantidad       = Convert.ToInt32(txtCantidad.Text),
                     fecha          = fecha.DisplayDate,
                     id_prod        = producto.id,
                     observaciones  = txtObservaciones.Text,
                     registrado_por = txtRegistradoPor.Text
                 };
                 if (prodperdiManager.crear(producto_perdido))
                 {
                     MessageBox.Show("Registrado");
                     CancelarTodo();
                 }
                 else
                 {
                     MessageBox.Show("Ha ocurrido un error " + proddañadaManager.Error.ToLower());
                 }
             }
         }
     }
 }
Exemple #3
0
 public bool eliminar(Produccion_Dañada entidad)
 {
     try
     {
         string     sql = "DELETE FROM produccion_dañada WHERE id=" + entidad.id;
         SqlCommand cmd = new SqlCommand(sql, db.conn);
         db.Conectar();
         db.Comando(cmd);
         db.Desconectar();
         Error = "";
         return(true);
     }
     catch (Exception ex)
     {
         Error = ex.Message;
         return(false);
     }
 }
Exemple #4
0
 public bool editar(Produccion_Dañada entidadanterior, Produccion_Dañada entidadmodificada)
 {
     try
     {
         string sql = "UPDATE produccion_dañada SET " +
                      "fecha='" + entidadmodificada.fecha + "', " +
                      "nombre_emp='" + entidadmodificada.nombre_emp + "', " +
                      "id_prod=" + entidadmodificada.id_prod + ", " +
                      "cantidad=" + entidadmodificada.cantidad + " WHERE id=" + entidadanterior.id;
         SqlCommand cmd = new SqlCommand(sql, db.conn);
         db.Conectar();
         db.Comando(cmd);
         db.Desconectar();
         Error = "";
         return(true);
     }
     catch (Exception ex)
     {
         Error = ex.Message;
         return(false);
     }
 }
Exemple #5
0
 public bool crear(Produccion_Dañada entidad)
 {
     try
     {
         string sql = "INSERT INTO produccion_dañada VALUES (" +
                      "'" + entidad.fecha.ToString("MM/dd/yyyy") + "', " +
                      "'" + entidad.nombre_emp + "', " +
                      "" + entidad.id_prod + ", " +
                      "" + entidad.cantidad + ")";
         SqlCommand cmd = new SqlCommand(sql, db.conn);
         db.Conectar();
         db.Comando(cmd);
         db.Desconectar();
         Error = "";
         return(true);
     }
     catch (Exception ex)
     {
         Error = ex.Message;
         return(false);
     }
 }
Exemple #6
0
 public bool eliminar(Produccion_Dañada entidad)
 {
     return(repo.eliminar(entidad));
 }
Exemple #7
0
 public bool editar(Produccion_Dañada entidadanterior, Produccion_Dañada entidadmodificada)
 {
     return(repo.editar(entidadanterior, entidadmodificada));
 }
Exemple #8
0
 public bool crear(Produccion_Dañada entidad)
 {
     return(repo.crear(entidad));
 }