}//fin editar //metodo eliminar public string Eliminar(DRecibo Recibo) {//inicio eliminar string rpta = ""; SqlConnection SqlCon = new SqlConnection(); try { //conexion SqlCon.ConnectionString = Conexion.Cn; SqlCon.Open(); //establecer el comando SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.CommandText = "speliminar_recibo"; SqlCmd.CommandType = CommandType.StoredProcedure; //parametros SqlParameter ParId_Recibo = new SqlParameter(); ParId_Recibo.ParameterName = "@id_recibo"; ParId_Recibo.SqlDbType = SqlDbType.Int; ParId_Recibo.Value = Recibo.Id_recibo; SqlCmd.Parameters.Add(ParId_Recibo); rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO SE HA ELIMINADO EL REGISTRO"; } catch (Exception ex) { rpta = ex.Message + ex.StackTrace; } finally { if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } } return(rpta); }//fin eliminar
}//fin insertar //metodo editar public string Editar(DRecibo Recibo) {//inicio editar string rpta = ""; SqlConnection SqlCon = new SqlConnection(); try { //conexion SqlCon.ConnectionString = Conexion.Cn; SqlCon.Open(); //establecer el comando SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.CommandText = "speditar_recibo"; SqlCmd.CommandType = CommandType.StoredProcedure; //parametros SqlParameter ParId_Recibo = new SqlParameter(); ParId_Recibo.ParameterName = "@id_recibo"; ParId_Recibo.SqlDbType = SqlDbType.Int; ParId_Recibo.Value = ParameterDirection.Output; SqlCmd.Parameters.Add(ParId_Recibo); SqlParameter ParNumero_Recibo = new SqlParameter(); ParNumero_Recibo.ParameterName = "@numero_recibo"; ParNumero_Recibo.SqlDbType = SqlDbType.Int; ParNumero_Recibo.Value = Recibo.Numero_recibo; SqlCmd.Parameters.Add(ParNumero_Recibo); SqlParameter ParFecha_Recibo = new SqlParameter(); ParFecha_Recibo.ParameterName = "@fecha_recibo"; ParFecha_Recibo.SqlDbType = SqlDbType.DateTime; ParFecha_Recibo.Value = Recibo.Fecha_recibo; SqlCmd.Parameters.Add(ParFecha_Recibo); SqlParameter ParId_Taller = new SqlParameter(); ParId_Taller.ParameterName = "@id_taller"; ParId_Taller.SqlDbType = SqlDbType.Int; ParId_Taller.Value = Recibo.Id_taller; SqlCmd.Parameters.Add(ParId_Taller); SqlParameter ParPersonal_Recibe = new SqlParameter(); ParPersonal_Recibe.ParameterName = "@personal_recibe"; ParPersonal_Recibe.SqlDbType = SqlDbType.VarChar; ParPersonal_Recibe.Size = 50; ParPersonal_Recibe.Value = Recibo.Personal_recibe; SqlCmd.Parameters.Add(ParPersonal_Recibe); //ejecutar el codigo rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "HA FALLADO LA EDICION DEL REGISTRO"; } catch (Exception ex) { rpta = ex.Message + ex.StackTrace; } finally { if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } } return(rpta); }//fin editar