private void btnReg_Click(object sender, EventArgs e) { //valida los textos if (txtPro.Text == "") { MessageBox.Show("Ingrese un producto", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPro.Focus(); } else if (txtPre.Text == "") { MessageBox.Show("Ingrese precio del producto", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPre.Focus(); } else if (txtSto.Text == "") { MessageBox.Show("Ingrese stock", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); txtSto.Focus(); } else if (txtIdCat.Text == "") { MessageBox.Show("Ingrese una categoria", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); txtIdCat.Focus(); } else if (txtIdCli.Text == "") { MessageBox.Show("Ingrese un cliente", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); txtIdCli.Focus(); } else { //guarda los datos en la entidad Producto_Enc Pro = new Producto_Enc(); Pro.Nom = txtPro.Text; double n = Convert.ToDouble(txtPre.Text); Pro.Pre = txtPre.Text; Pro.Stock = Convert.ToInt32(txtSto.Text); Pro.IdCat = Convert.ToInt32(txtIdCat.Text); Pro.IdUsu = VarGlo.CodUsu; Pro.IdCli = Convert.ToInt32(txtIdCli.Text); //ejecutamos la consulta regPro.RegPro_Gua(Pro); MessageBox.Show("Se registro corretamente el producto", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); Pro_LimTex(); } }
public void RegPro_Gua(Producto_Enc Pro) { using (SqlConnection cn = new SqlConnection(consulta)) { using (SqlCommand cmdGuaPro = new SqlCommand("SP_GuaPro", cn)) { cmdGuaPro.Connection.Open(); cmdGuaPro.CommandType = CommandType.StoredProcedure; cmdGuaPro.Parameters.Add("@Nom", SqlDbType.NVarChar, 50).Value = Pro.Nom; cmdGuaPro.Parameters.Add("@Pre", SqlDbType.NVarChar, 20).Value = Pro.Pre; cmdGuaPro.Parameters.Add("@Stock", SqlDbType.Int).Value = Pro.Stock; cmdGuaPro.Parameters.Add("@IdCat", SqlDbType.Int).Value = Pro.IdCat; cmdGuaPro.Parameters.Add("@IdUsu", SqlDbType.Int).Value = Pro.IdUsu; cmdGuaPro.Parameters.Add("@IdCli", SqlDbType.Int).Value = Pro.IdCli; cmdGuaPro.ExecuteNonQuery(); } } }
public void RegPro_Gua(Producto_Enc Pro) { regPro.RegPro_Gua(Pro); }