public byte ModificarServicio(ServicioClass newserv, ServicioClass oldserv) { try { conectar(); string qry = "sp_Servicios"; _comandosql = new SqlCommand(qry, _conexion); _comandosql.CommandType = CommandType.StoredProcedure; _comandosql.CommandTimeout = 9000; var param1 = _comandosql.Parameters.Add("@proc", SqlDbType.VarChar, 16); param1.Value = "update"; var param2 = _comandosql.Parameters.Add("@id_ser", SqlDbType.BigInt); param2.Value = oldserv.id_ser; if (newserv.med != oldserv.med) { var param3 = _comandosql.Parameters.Add("@med", SqlDbType.BigInt); param3.Value = newserv.med; } if (newserv.tipo_ser != oldserv.tipo_ser) { var param4 = _comandosql.Parameters.Add("@tip_ser", SqlDbType.Bit); param4.Value = newserv.tipo_ser; } if (newserv.dom != oldserv.dom) { var param5 = _comandosql.Parameters.Add("@dom", SqlDbType.VarChar, 128); param5.Value = newserv.dom.getAssembled(); } _adaptador.UpdateCommand = _comandosql; if (_comandosql.ExecuteNonQuery() == 0) { return(1); } return(0); } catch (SqlException e) { MessageBox.Show(e.ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(10); } finally { desconectar(); } }
public byte AgregarServicio(ServicioClass serv) { try { conectar(); string qry = "sp_Servicios"; _comandosql = new SqlCommand(qry, _conexion); _comandosql.CommandType = CommandType.StoredProcedure; _comandosql.CommandTimeout = 9000; var param1 = _comandosql.Parameters.Add("@proc", SqlDbType.VarChar, 16); param1.Value = "insert"; var param2 = _comandosql.Parameters.Add("@id_cl", SqlDbType.BigInt); param2.Value = serv.id_cl; var param3 = _comandosql.Parameters.Add("@num_emp", SqlDbType.Int); param3.Value = serv.num_emp; var param4 = _comandosql.Parameters.Add("@med", SqlDbType.BigInt); param4.Value = serv.med; var param5 = _comandosql.Parameters.Add("@tip_ser", SqlDbType.Bit); param5.Value = serv.tipo_ser; var param6 = _comandosql.Parameters.Add("@dom", SqlDbType.VarChar, 128); param6.Value = serv.dom.getAssembled(); _adaptador.InsertCommand = _comandosql; if (_comandosql.ExecuteNonQuery() == 0) { return(1); } return(0); } catch (SqlException e) { MessageBox.Show(e.ToString(), "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return(10); } finally { desconectar(); } }