コード例 #1
0
        public void GetPrendaxCod(Int32 CodPrenda)
        {
            txtFecha.Text = DateTime.Now.ToShortDateString();
            Clases.cPrenda prenda = new Clases.cPrenda();
            DataTable      trdo   = prenda.GetPrendaxCodigo(CodPrenda);

            Clases.cFunciones fun = new Clases.cFunciones();
            if (trdo.Rows.Count > 0)
            {
                txtDescripcion.Text = trdo.Rows[0]["Descripcion"].ToString();
                txtNombre.Text      = trdo.Rows[0]["Nombre"].ToString();
                txtApellido.Text    = trdo.Rows[0]["Apellido"].ToString();
                txtCodCliente.Text  = trdo.Rows[0]["CodCliente"].ToString();
                if (trdo.Rows[0]["CodPrenda"].ToString() != "")
                {
                    CargarPrenda(Convert.ToInt32(trdo.Rows[0]["CodPrenda"].ToString()));
                }
                txtPatente.Text = trdo.Rows[0]["Patente"].ToString();
                txtImporte.Text = trdo.Rows[0]["Importe"].ToString();
                if (txtImporte.Text != "")
                {
                    txtImporte.Text = fun.ParteEntera(txtImporte.Text);
                    txtImporte.Text = fun.FormatoEnteroMiles(txtImporte.Text);
                }
                txtCodVenta.Text   = trdo.Rows[0]["CodVenta"].ToString();
                txtDiferencia.Text = trdo.Rows[0]["Diferencia"].ToString();
                if (trdo.Rows[0]["ImportePagado"].ToString() != "")
                {
                    txtImporteaPagar.Text = trdo.Rows[0]["ImportePagado"].ToString();
                    txtImporteaPagar.Text = fun.ParteEntera(txtImporteaPagar.Text);
                    txtImporteaPagar.Text = fun.FormatoEnteroMiles(txtImporteaPagar.Text);
                }
                if (txtDiferencia.Text != "")
                {
                    txtDiferencia.Text = fun.ParteEntera(txtDiferencia.Text);
                    txtDiferencia.Text = fun.FormatoEnteroMiles(txtDiferencia.Text);
                }
                if (trdo.Rows[0]["FechaPago"].ToString() != "")
                {
                    DateTime fec = Convert.ToDateTime(trdo.Rows[0]["FechaPago"].ToString());
                    txtFecha.Text            = fec.ToShortDateString();
                    btnGrabar.Enabled        = false;
                    btnAnular.Enabled        = true;
                    txtImporteaPagar.Enabled = false;
                }
                else
                {
                    btnGrabar.Enabled        = true;
                    btnAnular.Enabled        = false;
                    txtImporteaPagar.Enabled = true;
                }
            }
            else
            {
                txtDescripcion.Text = "";
                txtNombre.Text      = "";
                txtApellido.Text    = "";
                Grilla.DataSource   = null;
            }
        }
コード例 #2
0
        private void GetPrendas()
        {
            Clases.cPrenda prenda  = new Clases.cPrenda();
            double         Importe = prenda.GetTotalPrenda();

            txtPrenda.Text = Importe.ToString();
            Clases.cFunciones fun = new Clases.cFunciones();
            txtPrenda.Text = fun.SepararDecimales(txtPrenda.Text);
            txtPrenda.Text = fun.FormatoEnteroMiles(txtPrenda.Text);
        }
コード例 #3
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            Clases.cFunciones fun = new Clases.cFunciones();
            if (fun.ValidarFecha(txtFechaDesde.Text) == false)
            {
                MessageBox.Show("Fecha desde incorrecta", Clases.cMensaje.Mensaje());
                return;
            }

            if (fun.ValidarFecha(txtFechaHasta.Text) == false)
            {
                MessageBox.Show("Fecha hasta incorrecta", Clases.cMensaje.Mensaje());
                return;
            }

            if (Convert.ToDateTime(txtFechaDesde.Text) > Convert.ToDateTime(txtFechaHasta.Text))
            {
                MessageBox.Show("La fecha desde debe ser inferior a la fecha hasta", Clases.cMensaje.Mensaje());
                return;
            }

            int Impagos = 0;

            if (chkImpagos.Checked == true)
            {
                Impagos = 1;
            }

            Clases.cPrenda prenda     = new Clases.cPrenda();
            DateTime       FechaDesde = Convert.ToDateTime(txtFechaDesde.Text);
            DateTime       FechaHasta = Convert.ToDateTime(txtFechaHasta.Text);
            DataTable      trdo       = prenda.GetPrendasxFecha(FechaDesde, FechaHasta, Impagos, txtPatente.Text, txtApellido.Text);

            txtTotal.Text = fun.TotalizarColumna(trdo, "Importe").ToString();
            if (txtTotal.Text != "")
            {
                txtTotal.Text = fun.SepararDecimales(txtTotal.Text);
                txtTotal.Text = fun.FormatoEnteroMiles(txtTotal.Text);
            }
            trdo = fun.TablaaMiles(trdo, "Importe");
            trdo = fun.TablaaMiles(trdo, "ImportePagado");
            trdo = fun.TablaaMiles(trdo, "Diferencia");
            Grilla.DataSource            = trdo;
            Grilla.Columns[1].HeaderText = "Descripción";
            Grilla.Columns[1].Width      = 150;
            Grilla.Columns[2].Width      = 350;
            Grilla.Columns[5].HeaderText = "Fecha Pago";
            Grilla.Columns[5].Width      = 140;
            Grilla.Columns[6].Visible    = false;
            Grilla.Columns[7].HeaderText = "Pagado";
            Grilla.Columns[8].HeaderText = "Diferencia";
        }
コード例 #4
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            Clases.cFunciones fun = new Clases.cFunciones();
            if (fun.ValidarFecha(txtFechaDesde.Text) == false)
            {
                MessageBox.Show("Fecha desde incorrecta", Clases.cMensaje.Mensaje());
                return;
            }

            if (fun.ValidarFecha(txtFechaHasta.Text) == false)
            {
                MessageBox.Show("Fecha hasta incorrecta", Clases.cMensaje.Mensaje());
                return;
            }

            if (Convert.ToDateTime(txtFechaDesde.Text) > Convert.ToDateTime(txtFechaHasta.Text))
            {
                MessageBox.Show("La fecha desde debe ser inferior a la fecha hasta", Clases.cMensaje.Mensaje());
                return;
            }

            int Impagos = 0;

            if (chkImpagos.Checked == true)
            {
                Impagos = 1;
            }

            Clases.cPrenda prenda     = new Clases.cPrenda();
            DateTime       FechaDesde = Convert.ToDateTime(txtFechaDesde.Text);
            DateTime       FechaHasta = Convert.ToDateTime(txtFechaHasta.Text);

            Clases.cEfectivoaPagar obj = new Clases.cEfectivoaPagar();
            DataTable trdo             = obj.GetEfectivosaPagarxFecha(FechaDesde, FechaHasta, txtPatente.Text.Trim(), Impagos);

            trdo = fun.TablaaMiles(trdo, "Saldo");
            trdo = fun.TablaaMiles(trdo, "Importe");
            Grilla.DataSource         = trdo;
            Grilla.Columns[0].Visible = true;
            Grilla.Columns[5].Width   = 150;
            Grilla.Columns[6].Width   = 150;
            Grilla.Columns[7].Width   = 240;
            txtTotal.Text             = fun.TotalizarColumna(trdo, "Saldo").ToString();
            if (txtTotal.Text != "")
            {
                txtTotal.Text = fun.FormatoEnteroMiles(txtTotal.Text);
            }
        }
コード例 #5
0
        private void btnAnular_Click(object sender, EventArgs e)
        {
            Clases.cFunciones fun = new Clases.cFunciones();

            /*
             * if (Grilla.Rows.Count < 2)
             * {
             *  MessageBox.Show("Debe Seleccionar una prenda para continuar ", Clases.cMensaje.Mensaje());
             *  return;
             * }
             *
             * if (Grilla.CurrentRow == null)
             * {
             *  MessageBox.Show("Seleccione una fila para continuar.", Clases.cMensaje.Mensaje());
             *  return;
             * }
             *
             * if (Grilla.CurrentRow.Cells[6].Value.ToString() == "")
             * {
             *  MessageBox.Show("La prenda no se puede anular debido a que no ha sido cobrada.", Clases.cMensaje.Mensaje());
             *  return;
             * }
             */
            string Descripcion = "ANULACION DE COBRO DE PRENDA:  Patente " + txtPatente.Text;

            Descripcion = Descripcion + ", Cliente " + txtNombre.Text;
            string CodPrenda = Principal.CodigoPrincipalAbm;
            Double Importe   = fun.ToDouble(txtImporte.Text);
            Int32  CodVenta  = Convert.ToInt32(txtCodVenta.Text);

            Clases.cPrenda prenda = new Clases.cPrenda();
            prenda.AnularPagoPrenda(Convert.ToInt32(CodPrenda));
            Clases.cMovimiento mov = new Clases.cMovimiento();
            if (txtDiferencia.Text != "0")
            {
                double Diferencia = fun.ToDouble(txtDiferencia.Text);
                string TEXTO      = "ANULACION DIFERENCIA PRENDA, PATENTE " + txtPatente.Text;
                // mov.RegistrarMovimientoDescripcion(CodVenta, Principal.CodUsuarioLogueado, (-1) * Diferencia, 0, 0, 0, 0, DateTime.Now, TEXTO);
            }
            DateTime Fecha = Convert.ToDateTime(txtFecha.Text);

            Clases.cCheque cheque = new Clases.cCheque();
            cheque.BorrarChequexCodPrenda(Convert.ToInt32(CodPrenda));
            Importe = fun.ToDouble(txtTotalCheque.Text);
            mov.RegistrarMovimientoDescripcion(CodVenta, Principal.CodUsuarioLogueado, (-1) * Importe, 0, 0, 0, 0, Fecha, Descripcion);
            MessageBox.Show("Datos grabados correctamente", Clases.cMensaje.Mensaje());
            GetPrendaxCod(Convert.ToInt32(CodPrenda));
        }
コード例 #6
0
        private double GetSaldoPrendaxCodVenta(Int32 CodVenta)
        {
            double Saldo = 0;

            Clases.cPrenda prenda  = new Clases.cPrenda();
            DataTable      tPrenda = prenda.GetPrendaxCodVenta(CodVenta);

            if (tPrenda.Rows.Count > 0)
            {
                if (tPrenda.Rows[0]["Saldo"].ToString() != "")
                {
                    Saldo = Convert.ToDouble(tPrenda.Rows[0]["Saldo"].ToString());
                }
            }
            return(Saldo);
        }
コード例 #7
0
        private void CargarPrenda(Int32 CodPrenda)
        {
            Clases.cFunciones fun    = new Clases.cFunciones();
            Clases.cPrenda    prenda = new Clases.cPrenda();
            DataTable         trdo   = prenda.GetPrendaxCodigo(CodPrenda);

            Grilla.DataSource            = fun.TablaaMiles(trdo, "Importe");
            Grilla.Columns[0].Visible    = false;
            Grilla.Columns[1].Visible    = false;
            Grilla.Columns[2].Width      = 120;
            Grilla.Columns[3].Visible    = false;
            Grilla.Columns[4].Visible    = false;
            Grilla.Columns[5].Visible    = false;
            Grilla.Columns[6].Width      = 108;
            Grilla.Columns[7].Visible    = false;
            Grilla.Columns[8].Width      = 480;
            Grilla.Columns[8].HeaderText = "Entidad";
            Grilla.Columns[6].HeaderText = "Fecha Pago";
        }
コード例 #8
0
        private void CargarDatos(Int32 CodVenta)
        {
            GetAutoPartePago(CodVenta);
            Clases.cCliente cliente = new Clases.cCliente();
            Clases.cVenta   venta   = new Clases.cVenta();
            DataTable       trdo    = venta.GetVentaxCodigo(CodVenta);

            if (trdo.Rows.Count > 0)
            {
                Int32     CodCliente = Convert.ToInt32(trdo.Rows[0]["CodCliente"].ToString());
                DataTable tcli       = cliente.GetClientesxCodigo(CodCliente);
                if (tcli.Rows.Count > 0)
                {
                    string nombre = tcli.Rows[0]["Nombre"].ToString();
                    nombre = nombre + " " + tcli.Rows[0]["Apellido"].ToString();
                    string Direccion = tcli.Rows[0]["Calle"].ToString();
                    Direccion         = Direccion + " " + tcli.Rows[0]["Numero"].ToString();
                    txtDireccion.Text = Direccion;
                    txtTelefono.Text  = tcli.Rows[0]["Telefono"].ToString();
                    txtNombre.Text    = nombre;
                }
            }
            txtEfectivo.Text   = trdo.Rows[0]["ImporteEfectivo"].ToString();
            txtDocumentos.Text = trdo.Rows[0]["ImporteCredito"].ToString();
            Int32 CodAuto = Convert.ToInt32(trdo.Rows[0]["CodAutoVendido"].ToString());

            Clases.cAuto auto  = new Clases.cAuto();
            DataTable    tauto = auto.GetAutoxCodigo(CodAuto);

            {
                if (tauto.Rows.Count > 0)
                {
                    string Descrip = tauto.Rows[0]["Descripcion"].ToString();
                    Descrip      = Descrip + " AÑO " + tauto.Rows[0]["Anio"].ToString();
                    Descrip      = Descrip + " DOMINIO " + tauto.Rows[0]["Patente"].ToString();
                    Descrip      = Descrip + " MOTOR N º" + tauto.Rows[0]["Motor"].ToString();
                    Descrip      = Descrip + " CHASIS N º" + tauto.Rows[0]["Chasis"].ToString();
                    txtAuto.Text = Descrip;
                }
            }
            Clases.cFunciones fun = new Clases.cFunciones();
            if (txtEfectivo.Text != "0" && txtEfectivo.Text != "")
            {
                txtEfectivo.Text = fun.SepararDecimales(txtEfectivo.Text);
                txtEfectivo.Text = fun.FormatoEnteroMiles(txtEfectivo.Text);
            }

            if (txtDocumentos.Text != "0" && txtDocumentos.Text != "")
            {
                txtDocumentos.Text = fun.SepararDecimales(txtDocumentos.Text);
                txtDocumentos.Text = fun.FormatoEnteroMiles(txtDocumentos.Text);
            }
            Clases.cPrenda prenda     = new Clases.cPrenda();
            DataTable      trdoPrenda = prenda.GetPrendaxCodVenta(Convert.ToInt32(Principal.CodigoPrincipalAbm));

            if (trdoPrenda.Rows.Count > 0)
            {
                string Importe = trdoPrenda.Rows[0]["Importe"].ToString();
                Importe = fun.SepararDecimales(Importe);
                Importe = fun.FormatoEnteroMiles(Importe);
                txtImportePrenda.Text = Importe;
            }
        }
コード例 #9
0
        private string GetFormasPago()
        {
            Clases.cFunciones fun   = new Clases.cFunciones();
            string            texto = "";
            int b = 0;

            if (txtSenia.Text != "")
            {
                texto = "Seña adelanto " + txtSenia.Text;
                b     = 1;
            }
            if (txtEfectivo.Text != "")
            {
                if (b == 0)
                {
                    texto = " efectivo en este acto " + txtEfectivo.Text;
                }
                else
                {
                    texto = texto + ",efectivo en este acto " + txtEfectivo.Text;
                }
                b = 1;
            }
            if (txtDocumentos.Text != "")
            {
                if (b == 0)
                {
                    texto = " Documento de " + txtDocumentos.Text;
                }
                else
                {
                    texto = texto + ", Documento de " + txtDocumentos.Text;
                }
            }

            if (txtAutoPartePago.Text != "")
            {
                texto = texto + txtAutoPartePago.Text;
            }

            // busco si hubo prenda
            Clases.cPrenda prenda = new Clases.cPrenda();
            DataTable      trdo   = prenda.GetPrendaxCodVenta(Convert.ToInt32(Principal.CodigoPrincipalAbm));

            if (trdo.Rows.Count > 0)
            {
                string Importe = trdo.Rows[0]["Importe"].ToString();
                Importe = fun.SepararDecimales(Importe);
                Importe = fun.FormatoEnteroMiles(Importe);
                string Descripcion = trdo.Rows[0]["Descripcion"].ToString();
                texto = texto + ",crédito prendario a cargo de " + Descripcion;
                texto = texto + ", por un valor de " + Importe;
            }

            texto = texto + ",sobre el cual se aplicaran los siguientes descuentos:";
            if (txtRentas.Text != "")
            {
                texto = texto + ", rentas :" + txtRentas.Text;
            }

            if (txtMunicipalidad.Text != "")
            {
                texto = texto + ", municipalidad :" + txtMunicipalidad.Text;
            }

            if (txtMultas.Text != "")
            {
                texto = texto + ", multas :" + txtMultas.Text;
            }

            if (txtMultas.Text != "")
            {
                texto = texto + ", rentas :" + txtMultas.Text;
            }

            if (txtVerificacion.Text != "")
            {
                texto = texto + ", verificación :" + txtVerificacion.Text;
            }

            if (txtFirmasyForm.Text != "")
            {
                texto = texto + ", firmas y form. :" + txtFirmasyForm.Text;
            }

            if (txtCancelacionPrenda.Text != "")
            {
                texto = texto + ", cancelac prenda. :" + txtCancelacionPrenda.Text;
            }

            if (txtOtros.Text != "")
            {
                texto = texto + ", cancelac prenda. :" + txtOtros.Text;
            }


            return(texto);
        }
コード例 #10
0
        private void btnAnular_Click(object sender, EventArgs e)
        {
            if (Grilla.CurrentRow == null)
            {
                MessageBox.Show("Debe seleccionar un registro para continuar ", Clases.cMensaje.Mensaje());
                return;
            }

            string msj    = "Confirma anular la venta ";
            var    result = MessageBox.Show(msj, "Información",
                                            MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question);

            // If the no button was pressed ...
            if (result == DialogResult.No)
            {
                return;
            }

            string Patente  = Grilla.CurrentRow.Cells[4].Value.ToString();
            string CodVenta = Grilla.CurrentRow.Cells[0].Value.ToString();

            //
            Int32  CodAutoPartePago1     = 0;
            Int32  CodAutoPartePago2     = 0;
            double ImportePagadoCobranza = 0;
            double ImportePagadoCuotas   = 0;
            double ImportePagadoPrenda   = 0;
            double ImportePagadoCheque   = 0;

            Clases.cVenta    objVenta2 = new Clases.cVenta();
            Clases.cCobranza cobranza  = new Clases.cCobranza();
            Clases.cPrenda   prenda    = new Clases.cPrenda();
            ImportePagadoCobranza = cobranza.GetImportePagado(Convert.ToInt32(CodVenta));
            Clases.cCuota  cuota  = new Clases.cCuota();
            Clases.cCheque cheque = new Clases.cCheque();
            ImportePagadoCuotas = cuota.ImportePagado(Convert.ToInt32(CodVenta));
            ImportePagadoPrenda = prenda.ImportePagado(Convert.ToInt32(CodVenta));
            ImportePagadoCheque = cheque.ImportePagado(Convert.ToInt32(CodVenta));
            DataTable tresult2 = objVenta2.GetAutosPartePago(Convert.ToInt32(CodVenta));

            for (int z = 0; z < tresult2.Rows.Count; z++)
            {
                if (z == 0)
                {
                    if (tresult2.Rows[0]["CodAuto"].ToString() != "")
                    {
                        CodAutoPartePago1 = Convert.ToInt32(tresult2.Rows[0]["CodAuto"].ToString());
                    }
                }

                if (z == 1)
                {
                    if (tresult2.Rows[0]["CodAuto"].ToString() != "")
                    {
                        CodAutoPartePago2 = Convert.ToInt32(tresult2.Rows[0]["CodAuto"].ToString());
                    }
                }
            }

            double ImporteAutoPartePago = 0;
            double ImporteCredito       = 0;
            double ImporteEfectivo      = 0;
            double ImportePrenda        = 0;
            double ImporteCobranza      = 0;
            double ImporteBanco         = 0;
            double CodAutoVendido       = -1;
            double CodAutoPartePago     = -1;
            double ImporteAutoNegativo  = 0;
            double ImporteSenia         = 0;

            Clases.cVenta objVenta = new Clases.cVenta();

            if (CodVenta != "")
            {
                Clases.cMovimiento objMov = new Clases.cMovimiento();
                ImporteAutoNegativo = objMov.GetImporteAutoNegativoxCodVenta(Convert.ToInt32(CodVenta));
                ImporteAutoNegativo = -1 * ImporteAutoNegativo;

                DataTable trdo = objVenta.GetVentaxCodigo(Convert.ToInt32(CodVenta));
                if (trdo.Rows.Count > 0)
                {
                    ImporteCredito  = Convert.ToDouble(trdo.Rows[0]["ImporteCredito"].ToString());
                    ImporteEfectivo = Convert.ToDouble(trdo.Rows[0]["ImporteEfectivo"].ToString());
                    ImportePrenda   = Convert.ToDouble(trdo.Rows[0]["ImportePrenda"].ToString());
                    ImporteCobranza = Convert.ToDouble(trdo.Rows[0]["ImporteCobranza"].ToString());
                    if (trdo.Rows[0]["PrecioSenia"].ToString() != "")
                    {
                        ImporteSenia = Convert.ToDouble(trdo.Rows[0]["PrecioSenia"].ToString());
                    }
                    ImporteEfectivo = ImporteEfectivo + ImporteSenia;
                    if (trdo.Rows[0]["CodAutoVendido"].ToString() != "")
                    {
                        CodAutoVendido = Convert.ToInt32(trdo.Rows[0]["CodAutoVendido"].ToString());
                    }

                    if (trdo.Rows[0]["CodAutoPartePago"].ToString() != "")
                    {
                        CodAutoPartePago = Convert.ToInt32(trdo.Rows[0]["CodAutoPartePago"].ToString());
                    }

                    if (trdo.Rows[0]["ImporteAutoPartePago"].ToString() != "")
                    {
                        ImporteAutoPartePago = Convert.ToDouble(trdo.Rows[0]["ImporteAutoPartePago"].ToString());
                    }

                    if (trdo.Rows[0]["ImporteBanco"].ToString() != "")
                    {
                        ImporteBanco = Convert.ToDouble(trdo.Rows[0]["ImporteBanco"].ToString());
                    }
                }

                //importe total del credito en documentos usado mas abajo
                double        ImporteTotalDocumento = 0;
                Clases.cCuota objCuotas             = new Clases.cCuota();
                ImporteTotalDocumento = objCuotas.GetSaldoDeudaCuotas(Convert.ToInt32(CodVenta));
                SqlConnection con = new SqlConnection();
                con.ConnectionString = Clases.cConexion.Cadenacon();
                con.Open();
                SqlTransaction Transaccion;
                Transaccion = con.BeginTransaction();
                SqlCommand Comand = new SqlCommand();
                Comand.Connection  = con;
                Comand.Transaction = Transaccion;
                try
                {
                    //vuelvo el auto al stock
                    //string sql = "insert into StockAuto(CodAuto,FechaAlta,CodUsuario)";
                    //sql = sql + " values(" + CodAutoVendido.ToString();
                    //sql = sql + "," + "'" + DateTime.Now.ToShortDateString() + "'";
                    //sql = sql + "," + Principal.CodUsuarioLogueado;
                    //sql = sql + ")";
                    string sql = "update StockAuto  set FechaBaja = null";
                    sql = sql + " where CodStock=";
                    sql = sql + " (select max(CodStock) from StockAuto sa ";
                    sql = sql + " where sa.CodAuto =" + CodAutoVendido.ToString();
                    sql = sql + ")";
                    Comand.CommandText = sql;
                    Comand.ExecuteNonQuery();
                    //si pago con un auto le doy de baja
                    if (CodAutoPartePago > 0)
                    {
                        SqlCommand Comand2 = new SqlCommand();
                        Comand2.Connection  = con;
                        Comand2.Transaction = Transaccion;
                        string sqlStock = "update StockAuto";
                        sqlStock            = sqlStock + " set FechaBaja =" + "'" + DateTime.Now.ToShortDateString() + "'";
                        sqlStock            = sqlStock + " where CodAuto =" + CodAutoPartePago;
                        Comand2.CommandText = sqlStock;
                        Comand2.ExecuteNonQuery();
                    }
                    //borro la venta
                    string     sql3    = "delete from venta where CodVenta=" + CodVenta.ToString();
                    SqlCommand Comand3 = new SqlCommand();
                    Comand3.Connection  = con;
                    Comand3.Transaction = Transaccion;
                    Comand3.CommandText = sql3;
                    Comand3.ExecuteNonQuery();

                    //borro las cuotas

                    string     sql4    = "delete from cuotas where CodVenta=" + CodVenta.ToString();
                    SqlCommand Comand4 = new SqlCommand();
                    Comand4.Connection  = con;
                    Comand4.Transaction = Transaccion;
                    Comand4.CommandText = sql4;
                    Comand4.ExecuteNonQuery();

                    //borro la prenda

                    string     sqlPrenda    = "delete from Prenda where CodVenta=" + CodVenta.ToString();
                    SqlCommand ComandPrenda = new SqlCommand();
                    ComandPrenda.Connection  = con;
                    ComandPrenda.Transaction = Transaccion;
                    ComandPrenda.CommandText = sqlPrenda;
                    ComandPrenda.ExecuteNonQuery();

                    //borro los cheques

                    string     sqlCheque    = "delete from Cheque where CodVenta=" + CodVenta.ToString();
                    SqlCommand ComandCheque = new SqlCommand();
                    ComandCheque.Connection  = con;
                    ComandCheque.Transaction = Transaccion;
                    ComandCheque.CommandText = sqlCheque;
                    ComandCheque.ExecuteNonQuery();

                    //si hubo un saldo de cobranza tb lo anulo
                    //ya que significa que habia pagado una cobranza
                    //y debo volver a sacar el efectivo cobrado

                    //borro las cobranzas

                    string     sqlCobranza    = "delete from Cobranza where CodVenta=" + CodVenta.ToString();
                    SqlCommand ComandCobranza = new SqlCommand();
                    ComandCobranza.Connection  = con;
                    ComandCobranza.Transaction = Transaccion;
                    ComandCobranza.CommandText = sqlCobranza;
                    ComandCobranza.ExecuteNonQuery();



                    //borro las comisiones
                    if (ImportePagadoCobranza > 0)
                    {
                        //vuelvo el efectivo atraz
                        ImporteEfectivo = ImporteEfectivo + ImportePagadoCobranza;
                        //
                    }

                    if (ImportePagadoCuotas > 0)
                    {
                        ImporteEfectivo = ImporteEfectivo + ImportePagadoCuotas;
                    }

                    if (ImportePagadoPrenda > 0)
                    {
                        ImporteEfectivo = ImporteEfectivo + ImportePagadoPrenda;
                    }

                    if (ImportePagadoCheque > 0)
                    {
                        ImporteEfectivo = ImporteEfectivo + ImportePagadoCheque;
                    }

                    string     sqlComision    = "delete from ComisionVendedor where CodVenta=" + CodVenta.ToString();
                    SqlCommand ComandComision = new SqlCommand();
                    ComandComision.Connection  = con;
                    ComandComision.Transaction = Transaccion;
                    ComandComision.CommandText = sqlComision;
                    ComandComision.ExecuteNonQuery();

                    //Inserto el movimiento con los valores opuesto
                    ImporteCredito        = ImporteCredito * (-1);
                    ImporteTotalDocumento = ImporteTotalDocumento * (-1);
                    ImporteEfectivo       = ImporteEfectivo * (-1);
                    ImportePrenda         = ImportePrenda * (-1);
                    ImporteCobranza       = ImporteCobranza * (-1);
                    ImporteBanco          = ImporteBanco * (-1);
                    ImporteAutoPartePago  = (-1) * ImporteAutoPartePago;


                    string Descrip = "ANULACION VENTA " + Patente.ToString();
                    string sql5    = "Insert into Movimiento(ImporteDocumento,ImporteEfectivo";
                    sql5 = sql5 + ",ImportePrenda,ImporteCobranza,CodUsuario,Fecha,ImporteAuto,ImporteBanco,Descripcion)";
                    sql5 = sql5 + "Values(" + ImporteTotalDocumento.ToString().Replace(",", ".");
                    sql5 = sql5 + "," + ImporteEfectivo.ToString().Replace(",", ".");
                    sql5 = sql5 + "," + ImportePrenda.ToString().Replace(",", ".");
                    sql5 = sql5 + "," + ImporteCobranza.ToString().Replace(",", ".");
                    sql5 = sql5 + "," + Principal.CodUsuarioLogueado.ToString();
                    sql5 = sql5 + "," + "'" + DateTime.Now.ToShortDateString() + "'";
                    sql5 = sql5 + "," + ImporteAutoPartePago.ToString().Replace(",", ".");
                    sql5 = sql5 + "," + ImporteBanco.ToString().Replace(",", ".");
                    sql5 = sql5 + "," + "'" + Descrip + "'";
                    sql5 = sql5 + ")";
                    //finalmente inserto el movimiento opuesto
                    //para que vuelva el valor de la cuenta vehiculo
                    SqlCommand Comand5 = new SqlCommand();
                    Comand5.Connection  = con;
                    Comand5.Transaction = Transaccion;
                    Comand5.CommandText = sql5;
                    Comand5.ExecuteNonQuery();

                    string sql5b = "Insert into Movimiento(ImporteDocumento,ImporteEfectivo";
                    sql5b = sql5b + ",ImportePrenda,ImporteCobranza,CodUsuario,Fecha,ImporteAuto,ImporteBanco)";
                    sql5b = sql5b + "Values(" + ImporteTotalDocumento.ToString().Replace(",", ".");
                    sql5b = sql5b + ",0";
                    sql5b = sql5b + ",0";
                    sql5b = sql5b + ",0";
                    sql5b = sql5b + "," + Principal.CodUsuarioLogueado.ToString();
                    sql5b = sql5b + "," + "'" + DateTime.Now.ToShortDateString() + "'";
                    sql5b = sql5b + "," + ImporteAutoNegativo.ToString().Replace(",", ".");
                    sql5b = sql5b + ",0";
                    sql5b = sql5b + ")";
                    //finalmente inserto el movimiento opuesto del auto
                    //para que vuelva el valor de la cuenta vehiculo
                    SqlCommand Comand5b = new SqlCommand();
                    Comand5b.Connection  = con;
                    Comand5b.Transaction = Transaccion;
                    Comand5b.CommandText = sql5b;
                    Comand5b.ExecuteNonQuery();

                    string     sql6    = "delete from VentasxAuto where CodVenta =" + CodVenta.ToString();
                    SqlCommand Comand6 = new SqlCommand();
                    Comand6.Connection  = con;
                    Comand6.Transaction = Transaccion;
                    Comand6.CommandText = sql6;
                    Comand6.ExecuteNonQuery();

                    string     sql7    = "delete from GastosPagar where CodVenta =" + CodVenta.ToString();
                    SqlCommand Comand7 = new SqlCommand();
                    Comand7.Connection  = con;
                    Comand7.Transaction = Transaccion;
                    Comand7.CommandText = sql7;
                    Comand7.ExecuteNonQuery();

                    // doy de baja los autos del stock que ingresaron
                    // como parte de pago
                    if (CodAutoPartePago1 > 0)
                    {
                        string sql8 = "update StockAuto set FechaBaja=" + "'" + DateTime.Now.ToShortDateString() + "'";
                        sql8 = sql8 + " where CodAuto=" + CodAutoPartePago1.ToString();
                        SqlCommand Comand8 = new SqlCommand();
                        Comand8.Connection  = con;
                        Comand8.Transaction = Transaccion;
                        Comand8.CommandText = sql8;
                        Comand8.ExecuteNonQuery();
                    }

                    Transaccion.Commit();
                    con.Close();
                    GetVentas();
                    MessageBox.Show("Venta anulada correctamente", Clases.cMensaje.Mensaje());
                }
                catch (Exception ex)
                {
                    Transaccion.Rollback();
                    MessageBox.Show("Hubo un error en el proceso de anulación de venta", Clases.cMensaje.Mensaje());
                }
            }
        }
コード例 #11
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            Clases.cFunciones fun = new Clases.cFunciones();
            if (Grilla.Rows.Count < 2)
            {
                MessageBox.Show("Debe Seleccionar una prenda para continuar ", Clases.cMensaje.Mensaje());
                return;
            }

            if (txtFecha.Text == "")
            {
                MessageBox.Show("Debe ingresar una fecha para continuar.", Clases.cMensaje.Mensaje());
                return;
            }

            if (fun.ValidarFecha(txtFecha.Text) == false)
            {
                MessageBox.Show("La fecha ingresada es incorrecta.", Clases.cMensaje.Mensaje());
                return;
            }

            if (txtTotalCheque.Text == "")
            {
                MessageBox.Show("El importe total del cheque debe ser superior a cero.", Clases.cMensaje.Mensaje());
                return;
            }

            if (txtTotalCheque.Text == "0")
            {
                MessageBox.Show("El importe total del cheque debe ser superior a cero.", Clases.cMensaje.Mensaje());
                return;
            }

            double Importe      = fun.ToDouble(txtImporte.Text);
            double ImportePagar = fun.ToDouble(txtTotalCheque.Text);
            double dif          = ImportePagar - Importe;

            if (dif != 0)
            {
                var result = MessageBox.Show("El importe a pagar es distinto al importe,Desea continuar?", "Información",
                                             MessageBoxButtons.YesNo,
                                             MessageBoxIcon.Question);

                // If the no button was pressed ...
                if (result == DialogResult.No)
                {
                    return;
                }
            }



            string Descripcion = "COBRO DE PRENDA:  PATENTE " + txtPatente.Text;

            Descripcion = Descripcion + ", CLIENTE " + txtNombre.Text;
            string CodPrenda = Principal.CodigoPrincipalAbm;
            //Double Importe = fun.ToDouble(Grilla.CurrentRow.Cells[2].Value.ToString());
            Int32    CodVenta = Convert.ToInt32(txtCodVenta.Text);
            DateTime Fecha    = Convert.ToDateTime(txtFecha.Text);

            Clases.cPrenda prenda = new Clases.cPrenda();
            prenda.RegistrarPagoPrenda(Convert.ToInt32(CodPrenda), Convert.ToDateTime(txtFecha.Text), ImportePagar, dif);
            Clases.cMovimiento mov = new Clases.cMovimiento();
            //mov.RegistrarMovimientoDescripcion(CodVenta, Principal.CodUsuarioLogueado, Importe, 0, ((-1) * Importe), 0, 0, Fecha, Descripcion);

            for (int i = 0; i < GrillaCheques.Rows.Count - 1; i++)
            {
                string sImporteCheque = GrillaCheques.Rows[i].Cells[1].Value.ToString();
                string sqlCheque      = "insert into Cheque(CodVenta,NroCheque,Importe,Fecha,FechaVencimiento,CodCliente,CodBanco,CodPrenda)";
                sqlCheque = sqlCheque + "values (" + CodVenta.ToString();
                sqlCheque = sqlCheque + "," + "'" + GrillaCheques.Rows[i].Cells[0].Value.ToString() + "'";
                sqlCheque = sqlCheque + "," + fun.ToDouble(sImporteCheque);
                sqlCheque = sqlCheque + "," + "'" + txtFecha.Text + "'";
                sqlCheque = sqlCheque + "," + "'" + GrillaCheques.Rows[i].Cells[2].Value.ToString() + "'";
                sqlCheque = sqlCheque + "," + txtCodCliente.Text;
                sqlCheque = sqlCheque + "," + CmbBanco.SelectedValue;
                sqlCheque = sqlCheque + "," + CodPrenda.ToString();
                sqlCheque = sqlCheque + ")";
                Clases.cDb.ExecutarNonQuery(sqlCheque);
            }
            if (dif > 0)
            {
                string TEXTO = "GANANCIA POR EXEDENTE DE PRENDA, PATENTE " + txtPatente.Text;
                //mov.RegistrarMovimientoDescripcion(CodVenta, Principal.CodUsuarioLogueado, dif , 0, 0, 0, 0, Fecha, TEXTO);
            }
            if (dif < 0)
            {
                string TEXTO = "PERDIDA POR FALTANTE DE PRENDA, PATENTE " + txtPatente.Text;
                // mov.RegistrarMovimientoDescripcion(CodVenta, Principal.CodUsuarioLogueado, dif, 0, 0, 0, 0, Fecha, TEXTO);
            }
            MessageBox.Show("Datos grabados correctamente", Clases.cMensaje.Mensaje());
            GetPrendaxCod(Convert.ToInt32(CodPrenda));
        }