private void btnFac_Click(object sender, EventArgs e) { if (txtId.Text == "") { MessageBox.Show("Ingrese cliente a facturar", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); txtCli.Focus(); } else if (txtNumPag.Text == "") { MessageBox.Show("Ingrese numero de pago", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information); txtNumPag.Focus(); } else { Fac_EncDet Fac = new Fac_EncDet(); Fac.IdFac = IdFactura; Fac.IdPro = IdProdcuto; Fac.Can = Convert.ToInt32(txtCan.Text); Fac.Pre = txtPre.Text; Fac.IdCli = Convert.ToInt32(txtId.Text); fac.FacFin(Fac); MessageBox.Show("Se factura correctamente", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); FacFin_LimTex(); } }
public void FacFin(Fac_EncDet Fac) { using (SqlConnection cn = new SqlConnection(consulta)) { using (SqlCommand cmdGuaFacFin = new SqlCommand("INSERT INTO Factura_Producto VALUES(@IdFac,@IdPro,@Can,@Pre,@IdCli)", cn)) { cmdGuaFacFin.Connection.Open(); cmdGuaFacFin.CommandType = CommandType.Text; cmdGuaFacFin.Parameters.Add("@IdFac", SqlDbType.Int).Value = Fac.IdFac; cmdGuaFacFin.Parameters.Add("@IdPro", SqlDbType.Int).Value = Fac.IdPro; cmdGuaFacFin.Parameters.Add("@Can", SqlDbType.Int).Value = Fac.Can; cmdGuaFacFin.Parameters.Add("@Pre", SqlDbType.Int).Value = Fac.Pre; cmdGuaFacFin.Parameters.Add("@IdCli", SqlDbType.Int).Value = Fac.IdCli; cmdGuaFacFin.ExecuteNonQuery(); } } }
public void FacFin(Fac_EncDet Fac) { fac.FacFin(Fac); }