public void TraeDocumentosDenuncia(long _plLlaveObj, long _plLlaveObjVinc) { _eListDoc = new List <cDocumento>(); _ds = null; _dDataSQL.ClearParameters(); _dDataSQL.AddParameter("@llave_obj", _plLlaveObj); _dDataSQL.AddParameter("@llave_obj_vinc", _plLlaveObjVinc); _ds = _dDataSQL.Ejecuta("sp_TraeDocumentosDenuncia"); Exception = _dDataSQL.Exception; if (Exception == null) { if (!(_ds == null || _ds.Tables.Count == 0 || _ds.Tables[0].Rows.Count == 0)) { foreach (DataRow _dr in _ds.Tables[0].Rows) { _eDocumento = new cDocumento { _lRowNum = (_dr["rnom"] == DBNull.Value ? 0 : Convert.ToInt64(_dr["rnom"])), _lLlaveDocumento = (_dr["llave_documento"] == DBNull.Value ? 0 : Convert.ToInt64(_dr["llave_documento"])), _sNombreDocumento = (_dr["nombre_documento"] == DBNull.Value ? "" : (string)_dr["nombre_documento"]), _lLlaveCatTipoDoc = (_dr["llave_cat_tipo_doc"] == DBNull.Value ? 0 : Convert.ToInt64(_dr["llave_cat_tipo_doc"])), _sNombreTipoDoc = (_dr["nombre_instancia"] == DBNull.Value ? "" : (string)_dr["nombre_instancia"]), _sFechaUltAc = (_dr["fecha_ult_act"] == DBNull.Value ? "" : (string)_dr["fecha_ult_act"]), _sVerDocumento = (_dr["VerDoc"] == DBNull.Value ? "" : (string)_dr["VerDoc"]) }; _eListDoc.Add(_eDocumento); } } } }
public void TraeDocumento(long _plLlaveDocumento, long _plLlaveTipoDoc) { _eListDoc = new List <cDocumento>(); _ds = null; _dDataSQL.ClearParameters(); _dDataSQL.AddParameter("@llave_documento", _plLlaveDocumento); _dDataSQL.AddParameter("@llave_tipo_doc", _plLlaveTipoDoc); _ds = _dDataSQL.Ejecuta("sp_TraeDocDenuncia"); Exception = _dDataSQL.Exception; if (Exception == null) { if (!(_ds == null || _ds.Tables.Count == 0 || _ds.Tables[0].Rows.Count == 0)) { foreach (DataRow _dr in _ds.Tables[0].Rows) { _eDocumento = new cDocumento { _sNombreDocumento = (_dr["nombre_documento"] == DBNull.Value ? "" : (string)_dr["nombre_documento"]), _bDocumento = (_dr["documento"] == DBNull.Value ? null : (byte[])_dr["documento"]) }; _eListDoc.Add(_eDocumento); } } } }
private double GetSaldoDocumento(Int32 CodOrden) { double Saldo = 0; cDocumento doc = new cDocumento(); Saldo = doc.GetSaldoDocumentoxCodOrden(CodOrden); return(Saldo); }
private void Buscar() { cMovimiento mov = new cMovimiento(); double Efectivo = mov.GetTotalEfectivo(); txtEfectivo.Text = Efectivo.ToString(); txtEfectivo.Text = fun.SepararDecimales(txtEfectivo.Text); txtEfectivo.Text = fun.FormatoEnteroMiles(txtEfectivo.Text); cDocumento doc = new cDocumento(); double ImporteDoc = doc.GetTotalDocumentos(); txtDocumentos.Text = ImporteDoc.ToString(); txtDocumentos.Text = fun.SepararDecimales(txtDocumentos.Text); txtDocumentos.Text = fun.FormatoEnteroMiles(txtDocumentos.Text); cCobroTarjeta cobro = new cCobroTarjeta(); txtTotalTarjeta.Text = cobro.GetTotal().ToString(); txtTotalTarjeta.Text = fun.SepararDecimales(txtTotalTarjeta.Text); txtTotalTarjeta.Text = fun.FormatoEnteroMiles(txtTotalTarjeta.Text); cCheque cheque = new cCheque(); txtTotalCheque.Text = cheque.GetTotalCheque().ToString(); txtTotalCheque.Text = fun.SepararDecimales(txtTotalCheque.Text); txtTotalCheque.Text = fun.FormatoEnteroMiles(txtTotalCheque.Text); cGarantia garantia = new cGarantia(); txtGarantia.Text = garantia.GetTotalGarantia().ToString(); txtGarantia.Text = fun.SepararDecimales(txtGarantia.Text); txtGarantia.Text = fun.FormatoEnteroMiles(txtGarantia.Text); cInsumo insumo = new cInsumo(); txtTotalInsumo.Text = insumo.GetTotalInsumo().ToString(); txtTotalInsumo.Text = fun.SepararDecimales(txtTotalInsumo.Text); txtTotalInsumo.Text = fun.FormatoEnteroMiles(txtTotalInsumo.Text); cVale vale = new cVale(); txtTotalVale.Text = vale.GetTotalVales().ToString(); txtTotalVale.Text = fun.SepararDecimales(txtTotalVale.Text); txtTotalVale.Text = fun.FormatoEnteroMiles(txtTotalVale.Text); cTransferencia tra = new Clases.cTransferencia(); txtTotalTransferencia.Text = tra.GetTotal().ToString(); txtTotalTransferencia.Text = fun.SepararDecimales(txtTotalTransferencia.Text); txtTotalTransferencia.Text = fun.FormatoEnteroMiles(txtTotalTransferencia.Text); cCuentaCorriente cuenta = new cCuentaCorriente(); Double ImporteCuenta = cuenta.GetTotal(); txtCuentaCorriente.Text = ImporteCuenta.ToString(); txtCuentaCorriente.Text = fun.SepararDecimales(txtCuentaCorriente.Text); txtCuentaCorriente.Text = fun.FormatoEnteroMiles(txtCuentaCorriente.Text); }
private void Buscar(Int32 CodDocumento) { cDocumento doc = new cDocumento(); DataTable trdo = doc.GetDocumentoxCodigo(CodDocumento); if (trdo.Rows.Count > 0) { txtNombre.Text = trdo.Rows[0]["Nombre"].ToString(); txtApellido.Text = trdo.Rows[0]["Apellido"].ToString(); txtImporte.Text = trdo.Rows[0]["Importe"].ToString(); txtSaldo.Text = trdo.Rows[0]["Saldo"].ToString(); txtOrden.Text = trdo.Rows[0]["CodOrden"].ToString(); txtPatente.Text = trdo.Rows[0]["Patente"].ToString(); if (txtImporte.Text != "") { txtImporte.Text = fun.SepararDecimales(txtImporte.Text); txtImporte.Text = fun.FormatoEnteroMiles(txtImporte.Text); } if (txtSaldo.Text != "") { txtSaldo.Text = fun.SepararDecimales(txtSaldo.Text); txtSaldo.Text = fun.FormatoEnteroMiles(txtSaldo.Text); } } cCobroDocumento cob = new cCobroDocumento(); DataTable tresul = cob.GetCobrosxCodDocumento(CodDocumento); tresul = fun.TablaaMiles(tresul, "Importe"); Grilla.DataSource = tresul; Grilla.Columns[0].Visible = false; Grilla.Columns[1].Visible = false; Grilla.Columns[3].Width = 120; if (txtSaldo.Text == "0") { btnGrabar.Enabled = false; } else { btnGrabar.Enabled = true; } }
private void btnAnular_Click(object sender, EventArgs e) { if (fun.ValidarFecha(txtFecha.Text) == false) { Mensaje("La fecha es incorrecta"); return; } DateTime Fecha = Convert.ToDateTime(txtFecha.Text); Int32 CodDocumento = Convert.ToInt32(frmPrincipal.CodigoPrincipal); Int32 CodOrden = Convert.ToInt32(txtOrden.Text); SqlConnection con = new SqlConnection(cConexion.Cadenacon()); con.Open(); SqlTransaction tranOrden; tranOrden = con.BeginTransaction("TranOrden"); try { double ImporteAnular = fun.ToDouble(Grilla.CurrentRow.Cells[3].Value.ToString()); cDocumento docu = new cDocumento(); docu.AnularCobro(con, tranOrden, CodDocumento, ImporteAnular); Int32 CodCobro = Convert.ToInt32(Grilla.CurrentRow.Cells[0].Value.ToString()); cCobroDocumento cob = new cCobroDocumento(); cob.BorrarCobroDocumento(con, tranOrden, CodCobro); string Descripcion = "ANULACION COBRO DE DOCUMENTO CLIENTE " + txtApellido.Text + " " + txtApellido.Text + " " + txtNombre.Text; Descripcion = Descripcion + ", PATENTE " + txtPatente.Text; cMovimiento mov = new cMovimiento(); mov.GrabarMovimientoTransaccion(con, tranOrden, -1 * ImporteAnular, Descripcion, Fecha, 1, CodOrden); tranOrden.Commit(); con.Close(); Mensaje("Datos anulados correctamente"); Buscar(CodDocumento); } catch (Exception ex) { tranOrden.Rollback(); con.Close(); } }
private void btnBuscarOrden_Click(object sender, EventArgs e) { if (fun.ValidarFecha(txtFechaDesde.Text) == false) { Mensaje("La fecha desde es incorrecta"); return; } if (fun.ValidarFecha(txtFechaHasta.Text) == false) { Mensaje("La fecha hasta es incorrecta"); return; } Int32?CodOrden = null; if (txtNroOrden.Text != "") { CodOrden = Convert.ToInt32(txtNroOrden.Text); } DateTime fechaDesde = Convert.ToDateTime(txtFechaDesde.Text); DateTime fechaHasta = Convert.ToDateTime(txtFechaHasta.Text); int SoloImpago = 0; if (chkSoloImpago.Checked) { SoloImpago = 1; } cDocumento doc = new cDocumento(); DataTable trdo = doc.GetDocumentosxFecha(fechaDesde, fechaHasta, SoloImpago, CodOrden); trdo = fun.TablaaMiles(trdo, "Importe"); trdo = fun.TablaaMiles(trdo, "Saldo"); Grilla.DataSource = trdo; Grilla.Columns[0].Visible = false; Grilla.Columns[1].Width = 70; Grilla.Columns[2].Width = 210; txtTotal.Text = fun.TotalizarColumna(trdo, "Saldo").ToString(); txtTotal.Text = fun.FormatoEnteroMiles(txtTotal.Text); }
private void BuscarVenta(Int32 CodVenta) { btnGrabarVenta.Enabled = false; btnCancelar.Enabled = false; tbVenta.Clear(); cVenta venta = new cVenta(); DataTable trdo = venta.GetDetalleVenta(CodVenta); for (int i = 0; i < trdo.Rows.Count; i++) { string CodInsumo = trdo.Rows[i]["CodInsumo"].ToString(); string Nombre = trdo.Rows[i]["Nombre"].ToString(); string Cantidad = trdo.Rows[i]["Cantidad"].ToString(); string Precio = trdo.Rows[i]["Precio"].ToString(); string Subtotal = trdo.Rows[i]["Subtotal"].ToString(); DataRow r = tbVenta.NewRow(); r[0] = CodInsumo.ToString(); r[1] = Nombre; r[2] = Cantidad; r[3] = Precio; r[4] = Subtotal; tbVenta.Rows.Add(r); } Grilla.DataSource = tbVenta; Grilla.Columns[0].Visible = false; Grilla.Columns[1].Width = 310; DataTable tb = venta.GetVenta(CodVenta); if (tb.Rows.Count > 0) { if (tb.Rows[0]["Efectivo"].ToString() != "") { Double Efectivo = 0; Efectivo = Convert.ToDouble(tb.Rows[0]["Efectivo"].ToString()); txtEfectivo.Text = fun.SepararDecimales(Efectivo.ToString()); txtEfectivo.Text = fun.FormatoEnteroMiles(Efectivo.ToString()); } if (tb.Rows[0]["CodCliente"].ToString() != "") { if (tb.Rows[0]["CodCliente"].ToString() != "") { Int32 CodCliente = Convert.ToInt32(tb.Rows[0]["CodCliente"].ToString()); cCliente cliente = new cCliente(); DataTable tbCliente = cliente.GetClientexCodigo(CodCliente); if (tbCliente.Rows.Count > 0) { txtCodCliente.Text = tbCliente.Rows[0]["CodCliente"].ToString(); txtNombre.Text = tbCliente.Rows[0]["Nombre"].ToString(); txtApellido.Text = tbCliente.Rows[0]["Apellido"].ToString(); txtNroDocumento.Text = tbCliente.Rows[0]["NroDocumento"].ToString(); txtTelefono.Text = tbCliente.Rows[0]["Telefono"].ToString(); if (tbCliente.Rows[0]["CodTipoDoc"].ToString() != "") { string CodTipoDoc = tbCliente.Rows[0]["CodTipoDoc"].ToString(); if (cmbTipoDoc.Items.Count > 0) { cmbTipoDoc.SelectedValue = CodTipoDoc; } } } } } cDocumento doc = new cDocumento(); DataTable tdoc = doc.GetDocumentoxCodVenta(CodVenta); if (tdoc.Rows.Count > 0) { if (tdoc.Rows[0]["Importe"].ToString() != "") { Double Importe = Convert.ToDouble(tdoc.Rows[0]["Importe"].ToString()); txtDocumento.Text = Importe.ToString(); txtDocumento.Text = fun.SepararDecimales(txtDocumento.Text); txtDocumento.Text = fun.FormatoEnteroMiles(txtDocumento.Text); } } else { txtDocumento.Text = "0"; } } BuscarTarjetaxCodVenta(CodVenta); BuscarCheque(CodVenta); }
private void GrabarFormaPago(SqlConnection con, SqlTransaction Transaccion, Int32?CodOrden, Int32?CodVenta) { DateTime Fecha = Convert.ToDateTime(txtFechaAltaOrden.Text); Int32 CodUsuario = 1; cMovimiento mov = new cMovimiento(); string Descripcion = "VENTA DE REPUESTO "; Int32 CodCliente = Convert.ToInt32(txtCodCliente.Text); // Descripcion = Descripcion + " " + txtApellido.Text; // Descripcion = Descripcion + " " + txtNombre.Text; // Descripcion = Descripcion + ", PATENTE " + txtPatente.Text; if (txtEfectivo.Text != "" && txtEfectivo.Text != "0") { double Efectivo = fun.ToDouble(txtEfectivo.Text); mov.GrabarMovimientoTransaccion(con, Transaccion, Efectivo, Descripcion, Fecha, CodUsuario, CodOrden); } if (txtDocumento.Text != "" && txtDocumento.Text != "0") { double Importe = fun.ToDouble(txtDocumento.Text); cDocumento doc = new cDocumento(); doc.InsertarDocumentoTransaccion(con, Transaccion, Fecha, Importe, CodOrden, CodCliente, CodVenta); } if (txtTotalTarjeta.Text != "" && txtTotalTarjeta.Text != "0") { cCobroTarjeta cobro = new cCobroTarjeta(); for (int k = 0; k < tbTarjeta.Rows.Count; k++) { double ImporteTarjeta = Convert.ToDouble(tbTarjeta.Rows[k]["Importe"].ToString()); Int32 Codtarjeta = Convert.ToInt32(tbTarjeta.Rows[k]["CodTarjeta"].ToString()); string Cupon = tbTarjeta.Rows[k]["Cupon"].ToString(); DateTime FechaEmision = Convert.ToDateTime(tbTarjeta.Rows[k]["FechaEmision"].ToString()); Double? Recargo = null; if (tbTarjeta.Rows[k]["Recargo"].ToString() != "") { Recargo = Convert.ToDouble(tbTarjeta.Rows[k]["Recargo"].ToString()); } cobro.Registrar(con, Transaccion, CodOrden, Fecha, Codtarjeta, ImporteTarjeta, Cupon, FechaEmision, Recargo, CodCliente, Convert.ToInt32(CodVenta)); } } if (txtTotalCheque.Text != "" && txtTotalCheque.Text != "0") { cCheque cheque = new cCheque(); for (int i = 0; i < tbCheques.Rows.Count; i++) { string NroCheque = tbCheques.Rows[i]["NroCheque"].ToString(); DateTime FechaVto = Convert.ToDateTime(tbCheques.Rows[i]["Fecha"].ToString()); double Importe = fun.ToDouble(tbCheques.Rows[i]["Importe"].ToString()); cheque.InsertarCheque(con, Transaccion, NroCheque, Importe, CodOrden, Fecha, FechaVto, CodCliente, Convert.ToInt32(CodVenta)); } } /* * if (txtImporteGarantia.Text != "" && txtImporteGarantia.Text != "0") * { * double ImporteGarantia = fun.ToDouble(txtImporteGarantia.Text); * cGarantia objGarantia = new cGarantia(); * objGarantia.Insertar(con, Transaccion, ImporteGarantia, CodOrden, Fecha); * } * */ }
private void btnBuscar_Click(object sender, EventArgs e) { int ConDeuda = 0; if (ChkVencida.Checked == true) { ConDeuda = 1; } Clases.cFunciones fun = new Clases.cFunciones(); Int32? CodOrden = null; DataTable tResul = fun.CrearTabla("Codigo;Tipo;Orden;Patente;Descripcion;Apellido;Telefono;Celular;Importe;Saldo;Fecha;Vencimiento;Cupon"); if (txtPatente.Text == "" && txtApellido.Text == "" && txtCodOrden.Text == "") { CodOrden = -1; } if (txtCodOrden.Text != "") { CodOrden = Convert.ToInt32(txtCodOrden.Text); } string Cupon = ""; if (txtCupon.Text != "") { Cupon = txtCupon.Text; } DateTime Fecha = Convert.ToDateTime(txtFecha.Text); string Valor = ""; cCheque cheque = new cCheque(); DataTable tcheque = cheque.GetChequesAdeudados(txtPatente.Text, txtApellido.Text, Fecha, ConDeuda, CodOrden); for (int i = 0; i < tcheque.Rows.Count; i++) { Valor = tcheque.Rows[i]["CodCheque"].ToString(); Valor = Valor + ";" + "Cheque"; Valor = Valor + ";" + tcheque.Rows[i]["CodOrden"].ToString(); Valor = Valor + ";" + tcheque.Rows[i]["Patente"].ToString(); Valor = Valor + ";" + tcheque.Rows[i]["Descripcion1"].ToString(); Valor = Valor + ";" + tcheque.Rows[i]["Apellido"].ToString(); Valor = Valor + ";" + tcheque.Rows[i]["Telefono"].ToString(); Valor = Valor + ";"; //+ tcheque.Rows[i]["Celular"].ToString(); Valor = Valor + ";" + tcheque.Rows[i]["Importe"].ToString(); Valor = Valor + ";" + tcheque.Rows[i]["Importe"].ToString(); Valor = Valor + ";" + tcheque.Rows[i]["Fecha"].ToString(); Valor = Valor + ";" + tcheque.Rows[i]["FechaVto"].ToString(); Valor = Valor + "; "; if (Cupon == "") { tResul = fun.AgregarFilas(tResul, Valor); } } cGarantia garant = new cGarantia(); DataTable tGar = garant.GetGarantiasAdeudadas(txtPatente.Text, txtApellido.Text, Fecha, ConDeuda, CodOrden); for (int i = 0; i < tGar.Rows.Count; i++) { Valor = tGar.Rows[i]["CodGarantia"].ToString(); Valor = Valor + ";" + "Garantía"; Valor = Valor + ";" + tGar.Rows[i]["CodOrden"].ToString(); Valor = Valor + ";" + tGar.Rows[i]["Patente"].ToString(); Valor = Valor + ";" + tGar.Rows[i]["Descripcion1"].ToString(); Valor = Valor + ";" + tGar.Rows[i]["Apellido"].ToString(); Valor = Valor + ";" + tGar.Rows[i]["Telefono"].ToString(); Valor = Valor + ";"; //+ tcheque.Rows[i]["Celular"].ToString(); Valor = Valor + ";" + tGar.Rows[i]["Importe"].ToString(); Valor = Valor + ";" + tGar.Rows[i]["Importe"].ToString(); Valor = Valor + ";" + tGar.Rows[i]["Fecha"].ToString(); Valor = Valor + "; "; Valor = Valor + "; "; if (Cupon == "") { tResul = fun.AgregarFilas(tResul, Valor); } } cDocumento doc = new cDocumento(); DataTable tdoc = doc.GetDocumentosAdeudados(txtPatente.Text, txtApellido.Text, Fecha, ConDeuda, CodOrden); for (int i = 0; i < tdoc.Rows.Count; i++) { Valor = tdoc.Rows[i]["CodDocumento"].ToString(); Valor = Valor + ";" + "Documento"; Valor = Valor + ";" + tdoc.Rows[i]["CodOrden"].ToString(); Valor = Valor + ";" + tdoc.Rows[i]["Patente"].ToString(); Valor = Valor + ";" + tdoc.Rows[i]["Descripcion1"].ToString(); Valor = Valor + ";" + tdoc.Rows[i]["Apellido"].ToString(); Valor = Valor + ";" + tdoc.Rows[i]["Telefono"].ToString(); Valor = Valor + ";"; //+ tcheque.Rows[i]["Celular"].ToString(); Valor = Valor + ";" + tdoc.Rows[i]["Importe"].ToString(); Valor = Valor + ";" + tdoc.Rows[i]["Importe"].ToString(); Valor = Valor + ";" + tdoc.Rows[i]["Fecha"].ToString(); Valor = Valor + "; "; Valor = Valor + "; "; if (Cupon == "") { tResul = fun.AgregarFilas(tResul, Valor); } } cCobroTarjeta cobro = new cCobroTarjeta(); DataTable tcobro = cobro.GetCobrotarjetaAdeudada(txtPatente.Text, txtApellido.Text, Fecha, ConDeuda, CodOrden, Cupon); for (int i = 0; i < tcobro.Rows.Count; i++) { Valor = tcobro.Rows[i]["CodCobro"].ToString(); Valor = Valor + ";" + "Tarjeta"; Valor = Valor + ";" + tcobro.Rows[i]["CodOrden"].ToString(); Valor = Valor + ";" + tcobro.Rows[i]["Patente"].ToString(); Valor = Valor + ";" + tcobro.Rows[i]["Descripcion1"].ToString(); Valor = Valor + ";" + tcobro.Rows[i]["Apellido"].ToString(); Valor = Valor + ";" + tcobro.Rows[i]["Telefono"].ToString(); Valor = Valor + ";"; //+ tcheque.Rows[i]["Celular"].ToString(); Valor = Valor + ";" + tcobro.Rows[i]["Importe"].ToString(); Valor = Valor + ";" + tcobro.Rows[i]["Importe"].ToString(); Valor = Valor + ";" + tcobro.Rows[i]["Fecha"].ToString(); Valor = Valor + "; "; Valor = Valor + ";" + tcobro.Rows[i]["Cupon"].ToString(); tResul = fun.AgregarFilas(tResul, Valor); } double Total = fun.TotalizarColumna(tResul, "Saldo"); txtTotal.Text = Total.ToString(); txtTotal.Text = fun.FormatoEnteroMiles(txtTotal.Text); tResul = fun.TablaaMiles(tResul, "Importe"); tResul = fun.TablaaMiles(tResul, "Saldo"); Grilla.DataSource = tResul; Grilla.Columns[0].Visible = false; //Grilla.Columns[4].Visible = false; Grilla.Columns[7].Visible = false; Pintar(); }
private void GetRentabilidad() { cCobroTarjeta objCobro = new cCobroTarjeta(); Clases.cFunciones fun = new Clases.cFunciones(); DateTime FechaDesde = Convert.ToDateTime(txtFechaDesde.Text); DateTime FechaHasta = Convert.ToDateTime(txtFechaHasta.Text); cOrden orden = new cOrden(); txtCantidad.Text = orden.CantidadOrdenes(FechaDesde, FechaHasta).ToString(); double Efectivo = orden.GetTotalEfectivo(FechaDesde, FechaHasta); txtEfectivo.Text = Efectivo.ToString(); if (txtEfectivo.Text != "") { txtEfectivo.Text = fun.FormatoEnteroMiles(txtEfectivo.Text); } double TotalTarjeta = 0; cCobroTarjeta cobro = new cCobroTarjeta(); TotalTarjeta = cobro.GetTotalTarjeta(FechaDesde, FechaHasta); // Double Saldo = cobro.GetSaldoxFecha(FechaDesde, FechaHasta); txtDiferenciaTarjeta.Text = Saldo.ToString(); TotalTarjeta = TotalTarjeta - Saldo; txtTarjeta.Text = TotalTarjeta.ToString(); if (txtTarjeta.Text != "") { txtTarjeta.Text = fun.FormatoEnteroMiles(txtTarjeta.Text); } if (txtDiferenciaTarjeta.Text != "") { txtDiferenciaTarjeta.Text = fun.FormatoEnteroMiles(txtDiferenciaTarjeta.Text); } cDocumento doc = new cDocumento(); double ImporteDocu = doc.GetTotalDocumento(FechaDesde, FechaHasta); txtImporteDocumento.Text = ImporteDocu.ToString(); if (txtImporteDocumento.Text != "") { txtImporteDocumento.Text = fun.FormatoEnteroMiles(txtImporteDocumento.Text); } cCheque cheque = new cCheque(); double ImporteCheque = cheque.GetTotalChequexFecha(FechaDesde, FechaHasta); txtcheque.Text = ImporteCheque.ToString(); if (txtcheque.Text != "") { txtcheque.Text = fun.FormatoEnteroMiles(txtcheque.Text); } cGarantia garantia = new cGarantia(); double ImporteGarantia = garantia.GetTotalGarantiaxFecha(FechaDesde, FechaHasta); txtGarantia.Text = ImporteGarantia.ToString(); if (txtGarantia.Text != "") { txtGarantia.Text = fun.FormatoEnteroMiles(txtGarantia.Text); } cCuentaCorriente cc = new cCuentaCorriente(); Double ImporteCuentaCorriene = 0; ImporteCuentaCorriene = cc.GetTotalCuentaxFecha(FechaDesde, FechaHasta); txtTotalCuentaCorriente.Text = ImporteCuentaCorriene.ToString(); if (txtTotalCuentaCorriente.Text != "") { txtTotalCuentaCorriente.Text = fun.FormatoEnteroMiles(txtTotalCuentaCorriente.Text); } cTransferencia tranfer = new cTransferencia(); Double ImporteTransferencia = tranfer.GetTotalTransferencia(FechaDesde, FechaHasta); txtTotalTransferencia.Text = ImporteTransferencia.ToString(); if (txtTotalTransferencia.Text != "") { txtTotalTransferencia.Text = fun.FormatoEnteroMiles(txtTotalTransferencia.Text); } double TotalFacturado = Efectivo + TotalTarjeta + ImporteDocu + ImporteCheque + ImporteGarantia + ImporteCuentaCorriene + ImporteTransferencia; txtTotalFacturado.Text = TotalFacturado.ToString(); if (txtTotalFacturado.Text != "") { txtTotalFacturado.Text = fun.FormatoEnteroMiles(txtTotalFacturado.Text); } double GananciaInsumos = orden.GetGananciaInsumo(FechaDesde, FechaHasta); double RecargoTarjeta = objCobro.GetTotalRecargoTarjeta(FechaDesde, FechaHasta); double VentaInsumo = orden.GetVentaInsumo(FechaDesde, FechaHasta); double CostoInsumo = orden.GetCostoInsumo(FechaDesde, FechaHasta); txtVentaInsumos.Text = VentaInsumo.ToString(); txtCostoInsumo.Text = CostoInsumo.ToString(); double GananciaInsuloMostrador = 0; cVenta objVenta = new cVenta(); double CostoMostrador = 0; CostoMostrador = objVenta.GetCostoInsumoVenta(FechaDesde, FechaHasta); txtCostoInsumoMostrador.Text = CostoMostrador.ToString(); //GetVentaInsumoVenta double VentaMostrador = 0; VentaMostrador = objVenta.GetVentaInsumoVenta(FechaDesde, FechaHasta); txtVentaMostrador.Text = VentaMostrador.ToString(); if (txtCostoInsumoMostrador.Text != "") { txtCostoInsumoMostrador.Text = fun.FormatoEnteroMiles(txtCostoInsumoMostrador.Text); } if (txtVentaMostrador.Text != "") { txtVentaMostrador.Text = fun.FormatoEnteroMiles(txtVentaMostrador.Text); } if (txtVentaInsumos.Text != "") { txtVentaInsumos.Text = fun.FormatoEnteroMiles(txtVentaInsumos.Text); } if (txtCostoInsumo.Text != "") { txtCostoInsumo.Text = fun.FormatoEnteroMiles(txtCostoInsumo.Text); } txtGananciaInsumos.Text = GananciaInsumos.ToString(); if (txtGananciaInsumos.Text != "") { txtGananciaInsumos.Text = fun.FormatoEnteroMiles(txtGananciaInsumos.Text); } GananciaInsuloMostrador = VentaMostrador - CostoMostrador; txtGananciaMostrador.Text = GananciaInsuloMostrador.ToString(); if (txtGananciaMostrador.Text != "") { txtGananciaMostrador.Text = fun.FormatoEnteroMiles(txtGananciaMostrador.Text); } double GananciaMo = orden.GetGananciaManoObra(FechaDesde, FechaHasta); txtManoObra.Text = GananciaMo.ToString(); if (txtManoObra.Text != "") { txtManoObra.Text = fun.FormatoEnteroMiles(txtManoObra.Text); } double TotalGanancia = GananciaInsumos + GananciaMo + RecargoTarjeta + GananciaInsuloMostrador - Saldo; txtTotalGanancia.Text = TotalGanancia.ToString(); if (txtTotalGanancia.Text != "") { txtTotalGanancia.Text = fun.FormatoEnteroMiles(txtTotalGanancia.Text); } double GastoAlquiler = 0; cGastosNegocio gasto = new cGastosNegocio(); Int32? CodEntidad = 11; GastoAlquiler = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); txtGastoAlquiler.Text = GastoAlquiler.ToString(); if (txtGastoAlquiler.Text != "") { txtGastoAlquiler.Text = fun.FormatoEnteroMiles(txtGastoAlquiler.Text); } double Sueldos = 0; CodEntidad = 6; Sueldos = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); txtSueldo.Text = Sueldos.ToString(); if (txtSueldo.Text != "") { txtSueldo.Text = fun.FormatoEnteroMiles(txtSueldo.Text); } double Combustible = 0; CodEntidad = 13; Combustible = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); txtCombustible.Text = Combustible.ToString(); if (txtCombustible.Text != "") { txtCombustible.Text = fun.FormatoEnteroMiles(txtCombustible.Text); } double Impuestos = 0; CodEntidad = 2; Impuestos = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); txtImpuesto.Text = Impuestos.ToString(); if (txtImpuesto.Text != "") { txtImpuesto.Text = fun.FormatoEnteroMiles(txtImpuesto.Text); } double Varios = 0; CodEntidad = null; Varios = gasto.GetGastosNegocio(FechaDesde, FechaHasta, CodEntidad); Varios = Varios - Sueldos - Impuestos - Combustible - GastoAlquiler; txtOtrosGastos.Text = Varios.ToString(); if (txtOtrosGastos.Text != "") { txtOtrosGastos.Text = fun.FormatoEnteroMiles(txtOtrosGastos.Text); } double TotalGastos = 0; TotalGastos = Varios + Sueldos + Impuestos + Combustible + GastoAlquiler; //+Saldo; txtTotalGastos.Text = TotalGastos.ToString(); if (txtTotalGastos.Text != "") { txtTotalGastos.Text = fun.FormatoEnteroMiles(txtTotalGastos.Text); } double Rentabilidad = TotalGanancia - TotalGastos; txtRentabilidad.Text = Rentabilidad.ToString(); if (txtRentabilidad.Text != "") { txtRentabilidad.Text = fun.FormatoEnteroMiles(txtRentabilidad.Text); } double SaldoGarantia = garantia.GetTotalSaldoGarantiaxFecha(FechaDesde, FechaHasta); txtSaldoGarantia.Text = SaldoGarantia.ToString(); if (txtSaldoGarantia.Text != "") { txtSaldoGarantia.Text = fun.FormatoEnteroMiles(txtSaldoGarantia.Text); } double TotalSaldoTarjeta = cobro.GetTotalSaldoTarjeta(FechaDesde, FechaHasta); txtSaldoTarjeta.Text = TotalSaldoTarjeta.ToString(); if (txtSaldoTarjeta.Text != "") { txtSaldoTarjeta.Text = fun.FormatoEnteroMiles(txtSaldoTarjeta.Text); } double ImporteSaldoDoc = doc.GetTotalSaldoDocumento(FechaDesde, FechaHasta); txtSaldoDocumento.Text = ImporteSaldoDoc.ToString(); if (txtSaldoDocumento.Text != "") { txtSaldoDocumento.Text = fun.FormatoEnteroMiles(txtSaldoDocumento.Text); } double ImporteSaldoCheque = cheque.GetTotalSaldoChequexFecha(FechaDesde, FechaHasta); txtSaldoCheque.Text = ImporteSaldoCheque.ToString(); if (txtSaldoCheque.Text != "") { txtSaldoCheque.Text = fun.FormatoEnteroMiles(txtSaldoCheque.Text); } }
private void EliminarOrden(Int32 CodOrden) { Double ImporteCobrodoDocumento = 0; Int32 CodDocumentoa = 0; Double ImporteEfectivoOrden = 0; Double ImporteCobradoTarjeta = 0; Double ImporteGatantia = 0; Double ImporteCheque = 0; cOrden orden = new cOrden(); cCobroDocumento cob = new cCobroDocumento(); cCobroTarjeta cobTarj = new cCobroTarjeta(); cGarantia garantia = new Clases.cGarantia(); cCobroCheque cobroCheque = new cCobroCheque(); cCheque cheque = new cCheque(); ImporteEfectivoOrden = orden.GetTotalEfectivoOrden(CodOrden); ImporteCobrodoDocumento = cob.GetTotalDocumentoCobrado(CodOrden); CodDocumentoa = cob.GetCodDocumentoxCodOrden(CodOrden); ImporteCobradoTarjeta = cobTarj.GetImporteCobradoxCodOrden(CodOrden); ImporteGatantia = garantia.GetImporteCobradoxCodOrden(CodOrden); ImporteCheque = cobroCheque.GetTotalChequeCobrado(CodOrden); cMovimiento mov = new cMovimiento(); cDocumento doc = new cDocumento(); SqlConnection con = new SqlConnection(cConexion.Cadenacon()); DateTime Fecha = DateTime.Now; string Descripcion = ""; con.Open(); SqlTransaction tran; tran = con.BeginTransaction("TranOrden"); try { if (ImporteEfectivoOrden > 0) { Descripcion = "Anulación Cobro de efectivo, Orden " + CodOrden.ToString(); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteEfectivoOrden, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } if (ImporteCobradoTarjeta > 0) { Descripcion = "Anulación Cobro de tarjeta, Orden " + CodOrden.ToString(); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteCobradoTarjeta, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } if (ImporteGatantia > 0) { Descripcion = "Anulación Cobro de garantía, Orden " + CodOrden.ToString(); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteGatantia, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } if (ImporteCheque > 0) { //saco los codcheque para borrar los cobros cheques DataTable tbcheque = cheque.GetChquesxCodOrden(CodOrden); if (tbcheque.Rows.Count > 0) { for (int i = 0; i < tbcheque.Rows.Count; i++) { if (tbcheque.Rows[i]["CodCheque"].ToString() != "") { Int32 CodCheque = Convert.ToInt32(tbcheque.Rows[i]["CodCheque"].ToString()); cobroCheque.BorrarCobroCheque(con, tran, CodCheque); } } } Descripcion = "Anulación Cobro de cheque, Orden " + CodOrden.ToString(); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteCheque, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } if (ImporteCobrodoDocumento > 0) { Descripcion = "Anulación Cobro de Documento, Orden " + CodOrden.ToString(); cob.BorrarCobroDocumentoxCodDocumento(con, tran, CodDocumentoa); mov.GrabarMovimientoTransaccion(con, tran, -1 * ImporteCobrodoDocumento, Descripcion, Fecha, Principal.CodUsuarioLogueado, null); } cTransferencia transferencia = new cTransferencia(); garantia.BorrarGarantia(con, tran, CodOrden); cheque.BorrarchquexCodOrden(con, tran, CodOrden); doc.BorrarDocumentoxCodOrden(con, tran, CodOrden); cobTarj.BorrarCobroTarjeta(con, tran, CodOrden); orden.EliminarOrden(con, tran, CodOrden); transferencia.BorrarTransferencia(con, tran, CodOrden); tran.Commit(); Mensaje("Orden de Trabajo eliminada correctamente, se actualizaron las cuentas"); con.Close(); Buscar(); } catch (Exception) { tran.Rollback(); con.Close(); Mensaje("Hubo un error en el proceso de anulación"); throw; } }