示例#1
0
        public DataTable Consulta_Nombre(D_Rutas dato)
        {
            DataTable     DtResultado = new DataTable("Rutas");
            SqlConnection SqlCon      = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = D_Conexion.Conexion;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "[sp_Rutas_Consulta_Nombre]";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParId = new SqlParameter();
                ParId.ParameterName = "@nombre";
                ParId.SqlDbType     = SqlDbType.VarChar;
                ParId.Value         = dato.Zona;
                SqlCmd.Parameters.Add(ParId);

                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtResultado);
            }
            catch (Exception)
            {
                DtResultado = null;
            }
            return(DtResultado);
        }
示例#2
0
        public DataTable Consulta_Id(D_Rutas rubro)
        {
            DataTable     DtResultado = new DataTable("Rutas");
            SqlConnection SqlCon      = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = D_Conexion.Conexion;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "[sp_Rutas_Consulta_Id]";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParId = new SqlParameter();
                ParId.ParameterName = "@Codigo";
                ParId.SqlDbType     = SqlDbType.Int;
                ParId.Value         = rubro.Codigo;
                SqlCmd.Parameters.Add(ParId);

                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtResultado);
            }
            catch (Exception)
            {
                DtResultado = null;
            }
            return(DtResultado);
        }
示例#3
0
        public string Eliminar(D_Rutas ruta)
        {
            string rpta = "";

            SqlCn = new SqlConnection();
            try
            {
                SqlCn.ConnectionString = D_Conexion.Conexion;
                SqlCn.Open();

                Sqlcmd             = new SqlCommand();
                Sqlcmd.Connection  = SqlCn;
                Sqlcmd.CommandText = "[sp_Rutas_Eliminar]";
                Sqlcmd.CommandType = CommandType.StoredProcedure;

                Sqlcmd.Parameters.AddWithValue("@Codigo", ruta.Codigo);

                rpta = Sqlcmd.ExecuteNonQuery() >= 1 ? "ok" : "No se elimino registro";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (SqlCn.State == ConnectionState.Open)
                {
                    SqlCn.Close();
                }
            }
            return(rpta);
        }
示例#4
0
        public string Editar(D_Rutas ruta)
        {
            try
            {
                SqlCn  = new SqlConnection();
                Sqlcmd = new SqlCommand();

                SqlCn.ConnectionString = D_Conexion.Conexion;
                SqlCn.Open();

                Sqltra = SqlCn.BeginTransaction();

                Sqlcmd.Connection  = SqlCn;
                Sqlcmd.Transaction = Sqltra;
                Sqlcmd.CommandText = "[sp_Rutas_Editar]";
                Sqlcmd.CommandType = CommandType.StoredProcedure;

                Sqlcmd.Parameters.AddWithValue("@Codigo", ruta.Codigo);
                Sqlcmd.Parameters.AddWithValue("@Descripcion", ruta.Descripcion);
                Sqlcmd.Parameters.AddWithValue("@Zona", ruta.Zona);

                resp = Sqlcmd.ExecuteNonQuery() >= 1 ? "ok" : "No se pudo Editar";


                if (resp.Equals("ok"))
                {
                    Sqltra.Commit();
                }
                else
                {
                    Sqltra.Rollback();
                }
            }

            catch (Exception ex)
            {
                resp = ex.Message;
            }
            finally
            {
                if (SqlCn.State == ConnectionState.Open)
                {
                    SqlCn.Close();
                }
            }
            return(resp);
        }