public ActionResult Create([Bind(Include = "FacturaAbonoId,FechaAbono,MontoAbono,Notas,FacturaId")] FacturaAbono abono) { if (ModelState.IsValid) { FacturaAbono obj = new FacturaAbono(); Facturas oFact = db.Facturas.DefaultIfEmpty(null).FirstOrDefault(f => f.FacturaId == abono.FacturaId); decimal saldo = oFact.Saldo; obj.FacturaId = abono.FacturaId; obj.FechaAbono = abono.FechaAbono; obj.MontoAbono = abono.MontoAbono; obj.SaldoAnterior = saldo; obj.Notas = abono.Notas; db.FacturaAbono.Add(obj); db.SaveChanges(); //descontando la factura oFact.Saldo = oFact.Saldo - obj.MontoAbono; if (oFact.Saldo == 0) { oFact.Cancelado = true; } db.Entry(oFact).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(abono)); }
public AbonoBanco() { InitializeComponent(); AbonoForm = this; objBancoDAO = new BancoDAO(); objComboBanco = new CuentaBanco(); objBancoDatos = new CuentaBanco(); objMonedaDao = new MonedaDAO(); objAbonoBancoDet = new AbonoBancoDet(); objAbonoBancoCab = new AbonoBancoCab(); objFacturaAbono = new FacturaAbono(); objAsientoDAO = new AsientoDAO(); objAsiento = new Asiento(); objAsientoDetalle = new AsientoDetalle(); cargarCmbBanco(); cmb_Banco.SelectedIndexChanged += Cmb_Banco_SelectedIndexChanged; txt_Fecha.Text = DateTime.Now.ToString("dd/MM/yyyy"); objComboBanco = (CuentaBanco)cmb_Banco.SelectedItem; objBancoDatos = objBancoDAO.listarBancoDatos(Ventas.UNIDADNEGOCIO, objComboBanco.Codigo, objComboBanco.Descripcion); txt_Cuenta.Text = objBancoDatos.Cuenta; txt_Moneda.Text = objBancoDatos.Moneda; txt_Tcambio.Text = objMonedaDao.getTipoCambioVenta(DateTime.Now.ToShortDateString()).ToString().PadRight(5, '0');; txt_MonedaCod.Text = objBancoDatos.MonedaCod; //gridParams(); grd_Detalle.CellClick += Grd_Detalle_CellClick; }
public List <FacturaAbono> getFacturaAbono(String codent, String Cliente) { List <FacturaAbono> objList = new List <FacturaAbono>(); FacturaAbono obj; Database db = DatabaseFactory.CreateDatabase("Conta"); DbCommand dbCommand = db.GetStoredProcCommand("sp_getDocumentosBanco", new object[] { codent, Cliente }); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { obj = new FacturaAbono(); obj.Serie = dataReader["Serie"].ToString(); obj.Numero = dataReader["Nro"].ToString(); obj.Total = convertToDouble(dataReader["Total"].ToString()); obj.Saldo = convertToDouble(dataReader["Saldo"].ToString()); obj.Fecha = dataReader["Fecha"].ToString(); obj.Tabla = dataReader["Tabla"].ToString(); obj.FechaVcto = dataReader["FechaVcto"].ToString(); obj.CuentaContable = dataReader["Cuenta"].ToString(); obj.MonedaCod = dataReader["MonedaCod"].ToString(); objList.Add(obj); } } return(objList); }
public BuscarFacturaBanco(String codCliente, Double cambio) { InitializeComponent(); this.StartPosition = FormStartPosition.Manual; this.Location = new Point(50, 20); objFacturaAbono = new FacturaAbono(); formAbono = AbonoBanco.AbonoForm; objBancoDAO = new BancoDAO(); tipoCambio = cambio; gridParams(); txt_BuscarDocumento.TextChanged += Txt_BuscarDocumento_TextChanged; objListBusquedaTotal = objBancoDAO.getFacturaAbono(Ventas.UNIDADNEGOCIO, codCliente); listDocumento(objListBusquedaTotal); objListBusqueda = objListBusquedaTotal; grdDocumento.CellValueChanged += GrdDocumento_CellValueChanged; grdDocumento.DoubleClick += GrdDocumento_DoubleClick; }
private void GrdDocumento_DoubleClick(object sender, EventArgs e) { index = grdDocumento.SelectedCells[0].RowIndex; // if (TipoBanco == "Q") { ojbVentas = objListBusquedaTotal[index]; formCaja.setDatosDoc(ojbVentas.Serie, ojbVentas.Numero, ojbVentas.Total); } else if (TipoBanco == "C") { ojbVentas = objListBusquedaTotal[index]; formVoucher.setDatosDoc(ojbVentas.Serie, ojbVentas.Numero, ojbVentas.Total, ojbVentas.VentasId, ojbVentas.Total); } else if (TipoBanco == "A") { objFacturaAbono = objListBusquedaTotalAbono[index]; formVoucher.setDatosAbono(objFacturaAbono.Serie, objFacturaAbono.Numero, objFacturaAbono.Saldo, objFacturaAbono.Total); } this.Close(); }
public BuscarDocVoucher(String Ruc, String operacion) { InitializeComponent(); TipoBusqueda = operacion; objVoucherDao = new VoucherDAO(); objFacturaAbono = new FacturaAbono(); objBancoDAO = new BancoDAO(); ojbVentas = new ContabilidadDTO.Ventas(); if (operacion == "C") { formCaja = Caja.CajaChica.formCajachica; } else if (operacion == "V") { formVoucher = Caja.EmisionVoucher.formEmision; TipoBanco = Caja.EmisionVoucher.TipoOperacionBanco; } if (TipoBanco == "A") { objListBusquedaAbono = objVoucherDao.geetDocumentoVoucherAbono(Ventas.UNIDADNEGOCIO, Ruc); gridParamsAbono(); grdDocumento.DataSource = objListBusquedaAbono; objListBusquedaTotalAbono = objListBusquedaAbono; } else { objListVentas = objVoucherDao.listarDocumentosVentas(Ruc, Ventas.UNIDADNEGOCIO /*,moneda,monedadoc*/); gridParams(); grdDocumento.DataSource = objListVentas; objListBusquedaTotal = objListVentas; } grdDocumento.Refresh(); grdDocumento.DoubleClick += GrdDocumento_DoubleClick; txt_BuscarDocumento.TextChanged += Txt_BuscarDocumento_TextChanged; }