コード例 #1
0
        //METODO BUSCAR
        public DataTable Buscar(DbdiPRVpProveedor bdiPRVpProveedor)
        {
            DataTable     DtResultado = new DataTable("bdiPRVpProveedor");
            SqlConnection SqlCon      = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = DConexion.CnBDActivo;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "usp_B_bdiPRVpProveedor";
                SqlCmd.CommandType = CommandType.StoredProcedure;



                SqlParameter ParName1 = new SqlParameter();
                ParName1.ParameterName = "@sLIFNR";
                ParName1.SqlDbType     = SqlDbType.Char;
                ParName1.Size          = 50;
                ParName1.Value         = bdiPRVpProveedor.LIFNR;
                SqlCmd.Parameters.Add(ParName1);

                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtResultado);
            }
            catch (Exception ex)
            {
                DtResultado = null;
            }
            return(DtResultado);
        }
コード例 #2
0
        //METODO INSERTAR
        public string Insertar(DbdiPRVpProveedor bdiPRVpProveedor)
        {
            string        rpta   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                //Código
                SqlCon.ConnectionString = DConexion.CnBDActivo;
                SqlCon.Open();
                //Establecer el Comando
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "usp_I_bdiPRVpProveedor";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParLIFNR = new SqlParameter();
                ParLIFNR.ParameterName = "@sLIFNR";
                ParLIFNR.SqlDbType     = SqlDbType.Char;
                ParLIFNR.Value         = bdiPRVpProveedor.LIFNR;
                SqlCmd.Parameters.Add(ParLIFNR);
                //
                SqlParameter PariName1 = new SqlParameter();
                PariName1.ParameterName = "@sName1";
                PariName1.SqlDbType     = SqlDbType.Char;
                PariName1.Value         = bdiPRVpProveedor.Name1;
                SqlCmd.Parameters.Add(PariName1);
                //
                SqlParameter ParsStras = new SqlParameter();
                ParsStras.ParameterName = "@sStras";
                ParsStras.SqlDbType     = SqlDbType.Char;
                ParsStras.Value         = bdiPRVpProveedor.Stras;
                SqlCmd.Parameters.Add(ParsStras);
                //
                SqlParameter ParsSTCD1 = new SqlParameter();
                ParsSTCD1.ParameterName = "@sSTCD1";
                ParsSTCD1.SqlDbType     = SqlDbType.Char;
                ParsSTCD1.Value         = bdiPRVpProveedor.STCD1;
                SqlCmd.Parameters.Add(ParsSTCD1);
                //

                //Ejecutamos nuestro comando

                rpta = SqlCmd.ExecuteNonQuery() != 0 ? "OK" : "NO se Elimino el Registro";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(rpta);
        }