public SearchClient()
 {
     InitializeComponent();
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
      CD_PROYECTO.MyConnection con = new CD_PROYECTO.MyConnection();
     SqlConnection conexion = con.CreateConnection();
 }
        private void cargarClientes()
        {
            CD_PROYECTO.MyConnection con = new CD_PROYECTO.MyConnection();
            SqlConnection conexion = con.CreateConnection();

            conexion.Open();
            SqlDataAdapter daClients = new SqlDataAdapter("sp_listClients",conexion);
            DataSet dsClients = new DataSet();
            daClients.Fill(dsClients, "Clients");
            dgv.DataSource = dsClients;
            dgv.DataMember = "Clients";

              conexion.Close();
        }
Exemple #3
0
        private void button6_Click(object sender, EventArgs e)
        {
            CD_PROYECTO.MyConnection con = new CD_PROYECTO.MyConnection();

            SqlConnection conexion = con.CreateConnection();
            SqlCommand commando = con.CreateCommand(conexion);
            SqlDataReader leer;
            commando.CommandText = "sp_searchById";
            commando.CommandType = CommandType.StoredProcedure;
            commando.Parameters.Add(new SqlParameter("@pId", txtID.Text));
            conexion.Open();
            leer = commando.ExecuteReader();
            if (leer.Read() == true)
            {
                MessageBox.Show("Registro Encontrado");
                txtID.Text = leer["id"].ToString();
                txtName.Text = leer["name"].ToString();
                txtLastName.Text = leer["lastname"].ToString();
                txtEmail.Text = leer["email"].ToString();
                txtPhone.Text = leer["phone"].ToString();
                cmbState.Text = leer["clientState"].ToString();
                cmbType.Text = leer["clientType"].ToString();
            }
            else
            {
                MessageBox.Show("Registro No Encontrado");
                txtID.Text = "";
                txtName.Text = "";
                txtLastName.Text = "";
                txtEmail.Text = "";
                txtPhone.Text = "";

            }
            conexion.Close();
        }