public Int32 InsertCredito(E_Credito ObjCredito) { CD_Credito objCD_Credito = new CD_Credito(AppSettings.GetConnectionString); Int32 CreditoID = 0; CreditoID = objCD_Credito.InsertCredito(ObjCredito); return(CreditoID); }
public Int32 InsertCredito(E_Credito ObjCredito) { SqlDatabase SqlClient = new SqlDatabase(connectionString); DbConnection tCnn; tCnn = SqlClient.CreateConnection(); tCnn.Open(); DbTransaction tran = tCnn.BeginTransaction(); Int32 CreditoID = 0; try { DbCommand SqlCommandAccess = SqlClient.GetStoredProcCommand("Ventas.Usp_InsertCredito"); SqlClient.AddInParameter(SqlCommandAccess, "@ClienteID", SqlDbType.Int, ObjCredito.ClienteID); SqlClient.AddInParameter(SqlCommandAccess, "@NomCampanha", SqlDbType.VarChar, ObjCredito.NomCampanha); SqlClient.AddInParameter(SqlCommandAccess, "@LineaCredito", SqlDbType.Decimal, ObjCredito.LineaCredito); SqlClient.AddInParameter(SqlCommandAccess, "@DiasFinanciar", SqlDbType.Int, ObjCredito.DiasFinanciar); SqlClient.AddInParameter(SqlCommandAccess, "@NumDeclaracionJurada", SqlDbType.VarChar, ObjCredito.NumDeclaracionJurada); SqlClient.AddInParameter(SqlCommandAccess, "@SedeIDCredito", SqlDbType.Char, ObjCredito.SedeIDCredito); SqlClient.AddInParameter(SqlCommandAccess, "@FechaInicio", SqlDbType.SmallDateTime, ObjCredito.FechaInicio); SqlClient.AddInParameter(SqlCommandAccess, "@EstadoID", SqlDbType.Int, ObjCredito.EstadoID); SqlClient.AddInParameter(SqlCommandAccess, "@UsuarioID", SqlDbType.Int, ObjCredito.UsuarioID); CreditoID = Convert.ToInt32(SqlClient.ExecuteScalar(SqlCommandAccess, tran)); tran.Commit(); tCnn.Close(); tCnn.Dispose(); SqlCommandAccess.Dispose(); return(CreditoID); } catch (Exception ex) { tran.Rollback(); throw new Exception(ex.Message); } }
public virtual void UpdateCredito(E_Credito ObjCredito) { SqlDatabase SqlClient = new SqlDatabase(connectionString); DbConnection tCnn; tCnn = SqlClient.CreateConnection(); tCnn.Open(); DbTransaction tran = tCnn.BeginTransaction(); try { DbCommand SqlCommandAccess = SqlClient.GetStoredProcCommand("[Ventas].[Usp_UpdateCredito]"); SqlClient.AddInParameter(SqlCommandAccess, "@CreditoID", SqlDbType.Int, ObjCredito.CreditoID); SqlClient.AddInParameter(SqlCommandAccess, "@ClienteID", SqlDbType.Int, ObjCredito.ClienteID); SqlClient.AddInParameter(SqlCommandAccess, "@NomCampanha", SqlDbType.VarChar, ObjCredito.NomCampanha); SqlClient.AddInParameter(SqlCommandAccess, "@LineaCredito", SqlDbType.Decimal, ObjCredito.LineaCredito); SqlClient.AddInParameter(SqlCommandAccess, "@CreditoDisponible", SqlDbType.Decimal, ObjCredito.CreditoDisponible); SqlClient.AddInParameter(SqlCommandAccess, "@DiasFinanciar", SqlDbType.Int, ObjCredito.DiasFinanciar); SqlClient.AddInParameter(SqlCommandAccess, "@NumDeclaracionJurada", SqlDbType.VarChar, ObjCredito.NumDeclaracionJurada); SqlClient.AddInParameter(SqlCommandAccess, "@SedeIDCredito", SqlDbType.Char, ObjCredito.SedeIDCredito); SqlClient.AddInParameter(SqlCommandAccess, "@FechaInicio", SqlDbType.SmallDateTime, ObjCredito.FechaInicio); SqlClient.AddInParameter(SqlCommandAccess, "@EstadoID", SqlDbType.Int, ObjCredito.EstadoID); SqlClient.AddInParameter(SqlCommandAccess, "@UsuarioID", SqlDbType.Int, ObjCredito.UsuarioID); SqlClient.ExecuteNonQuery(SqlCommandAccess, tran); tran.Commit(); tCnn.Close(); tCnn.Dispose(); SqlCommandAccess.Dispose(); } catch (Exception ex) { tran.Rollback(); throw new Exception(ex.Message); } }
private void BtnAprobar_Click(object sender, EventArgs e) { ErrProvider.Clear(); try { //validar if (TxtLineaCredito.Text != "" & TxtDiasFinanciar.Text != "") { //insertar crédito Int32 CreditoID = 0; if (LblCreditoID.Text != "") { CreditoID = Convert.ToInt32(LblCreditoID.Text); } //obtener datos del crédito E_Credito ObjCredito = new E_Credito(); ObjCredito.CreditoID = CreditoID; ObjCredito.ClienteID = Convert.ToInt32(useCliente1.cbCliente.Columns["ClienteID"].Value); if (TxtNomCampanha.Text == "") { ObjCredito.NomCampanha = DeFechaInicio.Value.ToString(); } else { ObjCredito.NomCampanha = TxtNomCampanha.Text; } ObjCredito.LineaCredito = Convert.ToDecimal(TxtLineaCredito.Text); ObjCredito.DiasFinanciar = Convert.ToInt32(TxtDiasFinanciar.Text); if (TxtCreditoDisponible.Text != "") { ObjCredito.CreditoDisponible = Convert.ToDecimal(TxtCreditoDisponible.Text); } ObjCredito.NumDeclaracionJurada = TxtNumDeclaracionJurada.Text; ObjCredito.SedeIDCredito = AppSettings.SedeID; ObjCredito.FechaInicio = Convert.ToDateTime(DeFechaInicio.Value); ObjCredito.EstadoID = 0;//planeado ObjCredito.UsuarioID = AppSettings.UserID; if (Accion == "N") { CreditoID = ObjCL_Credito.InsertCredito(ObjCredito); MessageBox.Show("Se guardo el crédito correctamente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); habilitar(true); limpiar(); //limpiar useCliente1_ComboValueChange(); //refrescar habilitar(false); } else if (Accion == "M") { ObjCL_Credito.UpdateCredito(ObjCredito); MessageBox.Show("Se edito el crédito correctamente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); habilitar(true); limpiar(); //limpiar useCliente1_ComboValueChange(); //refrescar habilitar(false); } else if (Accion == "E") { if (MessageBox.Show("¿Seguro que desea anular el crédito?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { ObjCredito.EstadoID = 10; ObjCL_Credito.UpdateCredito(ObjCredito); MessageBox.Show("Se deshabilito el crédito correctamente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); habilitar(true); limpiar(); //limpiar useCliente1_ComboValueChange(); //refrescar habilitar(false); } } Accion = ""; } else { if (TxtLineaCredito.Text == "") { ErrProvider.SetError(TxtLineaCredito, "Ingrese el monto de crédito"); } if (TxtDiasFinanciar.Text == "") { ErrProvider.SetError(TxtDiasFinanciar, "Ingrese los días a financiar el crédito"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void UpdateCredito(E_Credito ObjCredito) { CD_Credito objCD_Credito = new CD_Credito(AppSettings.GetConnectionString); objCD_Credito.UpdateCredito(ObjCredito); }