コード例 #1
0
        public void VerificaModificacionVentasPagos(Ventas_Pagos objPagos, int intCodigoVenta)
        {
            //Si tiene un codigo asignado es porque el contacto ya existia
            //Tambien debo tener el cuenta la transaccion que hizo con el campo intEstado
            //para esto se debera considerar los valores (0,1,2,3)


            if (objPagos.IntCodigo != 0)
            //El contacto ya existia
            {
                //Me fijo que hay que hacer con el contacto
                if (objPagos.IntEstado == 2)//Modifico
                {
                    ModificaVentasPagos(objPagos);
                }
                if (objPagos.IntEstado == 3)//Elimino
                {
                    EliminaVentasPago(objPagos.IntCodigo);
                }
                //sino no hago nada, todo queda como esta
            }
            else
            {
                //En este caso debe ser un alta de un contacto
                //Hay que tener en cuenta todos los estados menos el 3, que es el de baja
                if (objPagos.IntEstado != 3)
                {
                    GrabarVentasPagos(objPagos, intCodigoVenta);
                }
            }
        }
コード例 #2
0
        public List <Ventas_Pagos> BuscoPagos(int intCodigo)
        {
            string              strSql;
            Ventas_Pagos        objPagos;
            List <Ventas_Pagos> listPagos = new List <Ventas_Pagos>();

            strSql  = "select ventas_pagos_id,ventas_id,fecha,importe, cierrecajaid, mediopago ";
            strSql += "from Ventas_Pagos where ventas_id=" + intCodigo;
            LlenaCombos objLlenaCombos2 = new LlenaCombos();
            DataTable   dt2             = objLlenaCombos2.GetSqlDataAdapterbySql(strSql);

            if (dt2 != null)
            {
                for (int i = 0; i < dt2.Rows.Count; i++)
                {
                    objPagos               = new Ventas_Pagos();
                    objPagos.IntCodigo     = Convert.ToInt32(dt2.Rows[i]["ventas_pagos_id"].ToString());
                    objPagos.DtFecha       = Convert.ToDateTime(dt2.Rows[i]["fecha"].ToString());
                    objPagos.DeImporte     = Convert.ToDecimal(dt2.Rows[i]["importe"].ToString());
                    objPagos.IntNumeroCaja = Convert.ToInt32(dt2.Rows[i]["cierrecajaid"].ToString());
                    objPagos.IntMedioPago  = Convert.ToInt32(dt2.Rows[i]["mediopago"].ToString());

                    listPagos.Add(objPagos);
                }
            }
            return(listPagos);
        }
コード例 #3
0
        public void GrabarVentasPagos(Ventas_Pagos objPagos, int intVenta)
        {
            ManejaConexiones oManejaConexiones2 = new ManejaConexiones();

            SqlParameter[] spParam5 = new SqlParameter[5];

            spParam5[0]       = new SqlParameter("@ventas_id", SqlDbType.BigInt);
            spParam5[0].Value = intVenta;

            spParam5[1]       = new SqlParameter("@fecha", SqlDbType.DateTime);
            spParam5[1].Value = objPagos.DtFecha;

            spParam5[2]       = new SqlParameter("@importe", SqlDbType.Money);
            spParam5[2].Value = objPagos.DeImporte;

            spParam5[3]       = new SqlParameter("@cierrecajaid", SqlDbType.BigInt);
            spParam5[3].Value = objPagos.IntNumeroCaja;

            spParam5[4]       = new SqlParameter("@mediopago", SqlDbType.Int);
            spParam5[4].Value = objPagos.IntMedioPago;


            oManejaConexiones2.NombreStoredProcedure = "Add_Ventas_Pagos";
            oManejaConexiones2.Parametros            = spParam5;
            oManejaConexiones2.executeNonQuery();
        }
コード例 #4
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (!VerificoCamposAntesDeGrabar())
            {
                MessageBox.Show("Campos Obligatorios Incompletos");
                return;
            }

            if (this.modifica != -1)
            {
                //Si se esta modificando, modifico la lista en ese indice
                list.ElementAt(this.modifica).DtFecha       = Convert.ToDateTime(dtpFecha.Value);
                list.ElementAt(this.modifica).DeImporte     = Convert.ToDecimal(txtImporte.Text.Replace('.', ','));
                list.ElementAt(this.modifica).IntMedioPago  = Convert.ToInt32(cboMedioDePago.SelectedValue);
                list.ElementAt(this.modifica).IntNumeroCaja = intNumeroCaja;
                list.ElementAt(this.modifica).IntEstado     = 2;//Modificacion
            }
            else
            {
                objPagos               = new Ventas_Pagos();
                objPagos.DtFecha       = Convert.ToDateTime(dtpFecha.Value);
                objPagos.DeImporte     = Convert.ToDecimal(txtImporte.Text.Replace('.', ','));
                objPagos.IntMedioPago  = Convert.ToInt32(cboMedioDePago.SelectedValue);
                objPagos.IntNumeroCaja = intNumeroCaja;
                objPagos.IntEstado     = 1;//Alta

                this.list.Add(objPagos);
            }
            LimpiarControles();
            CargoGrilla();
        }
コード例 #5
0
        public frmClienteCtaCte(Int32 intClienteid, decimal deDebe)
        {
            InitializeComponent();

            objConfiguracion = objManejaConfiguracion.BuscarConfiguracion(Environment.MachineName);

            CargoCombos();
            this.deDebe       = deDebe;
            txtDebe.Text      = Convert.ToString(Redondeo(deDebe));
            objPagos          = new Ventas_Pagos();
            this.intClienteid = intClienteid;
            dtpFecha.Value    = DateTime.Now;
        }
コード例 #6
0
        public void ModificaVentasPagos(Ventas_Pagos objPagos)
        {
            ManejaConexiones oManejaConexiones2 = new ManejaConexiones();

            SqlParameter[] spParam5 = new SqlParameter[4];

            spParam5[0]       = new SqlParameter("@ventas_pagos_id", SqlDbType.BigInt);
            spParam5[0].Value = objPagos.IntCodigo;

            spParam5[1]       = new SqlParameter("@fecha", SqlDbType.DateTime);
            spParam5[1].Value = objPagos.DtFecha;

            spParam5[2]       = new SqlParameter("@importe", SqlDbType.Money);
            spParam5[2].Value = objPagos.DeImporte;

            spParam5[3]       = new SqlParameter("@mediopago", SqlDbType.Int);
            spParam5[3].Value = objPagos.IntMedioPago;

            oManejaConexiones2.NombreStoredProcedure = "Upd_Ventas_Pagos";
            oManejaConexiones2.Parametros            = spParam5;
            oManejaConexiones2.executeNonQuery();
        }
コード例 #7
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            string message;
            string caption = "Mensaje";

            //Primero me tengo que fijar si el cliente tiene alguna Carta de Porte asociada
            message = "Esta seguro que quiere descontar: $" + Convert.ToString(Redondeo(Convert.ToDecimal(txtImporte.Text.Replace('.', ','))));


            if (!VerificoCamposAntesDeGrabar())
            {
                MessageBox.Show("Campos Obligatorios Incompletos");
                return;
            }
            else
            {
                if (deDebe < Convert.ToDecimal(txtImporte.Text.Replace('.', ',')))
                {
                    MessageBox.Show("El cambo Importe no puede se mayor a lo que debe");
                    return;
                }


                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult      result;

                // Displays the MessageBox.

                result = MessageBox.Show(message, caption, buttons);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    ManejaVentas        objManejaVentas = new ManejaVentas();
                    List <Ventas>       list            = new List <Ventas>();
                    List <Ventas_Pagos> listPagos       = new List <Ventas_Pagos>();
                    decimal             deDiferencia    = deDebe;
                    int i = 0;



                    //Debo buscar las facturas impagas que tiene
                    //y descontar del total
                    //Si el total supera el de la factura, descontar de la siguiente y asi sucesivamente

                    //Busco las facturas impagas
                    list = objManejaVentas.BuscoFacturasConDeuda(intClienteid);

                    //Las recorro y voy descontando

                    foreach (var item in list)
                    {
                        if (deDiferencia > 0)
                        {
                            i++;
                            objPagos               = new Ventas_Pagos();
                            objPagos.IntEstado     = 1;//Alta
                            objPagos.DtFecha       = Convert.ToDateTime(dtpFecha.Value);
                            objPagos.IntMedioPago  = Convert.ToInt32(cboMedioDePago.SelectedValue);
                            objPagos.IntNumeroCaja = objConfiguracion.IntNumeroCaja;

                            if (i == 1)
                            {
                                if (item.DoDebe > Convert.ToDecimal(txtImporte.Text.Replace('.', ',')))
                                {
                                    objPagos.DeImporte = Convert.ToDecimal(txtImporte.Text.Replace('.', ','));
                                    deDiferencia       = 0;
                                    deDebe             = deDebe - objPagos.DeImporte;
                                }
                                else
                                {
                                    objPagos.DeImporte = item.DoDebe;
                                    deDiferencia       = Convert.ToDecimal(txtImporte.Text.Replace('.', ',')) - item.DoDebe;
                                    deDebe             = deDebe - item.DoDebe;
                                }
                            }
                            else
                            {
                                if (item.DoDebe > deDiferencia)
                                {
                                    objPagos.DeImporte = deDiferencia;;
                                    deDebe             = deDebe - deDiferencia;
                                    deDiferencia       = 0;
                                }
                                else
                                {
                                    objPagos.DeImporte = item.DoDebe;
                                    deDiferencia       = deDiferencia - item.DoDebe;
                                    deDebe             = deDebe - item.DoDebe;
                                }
                            }
                            //Grabo el pago
                            objManejaVentas.GrabarVentasPagos(objPagos, item.IntCodigo);

                            //Grabo el detalle de venta
                            item.DoPago = item.DoPago + objPagos.DeImporte;
                            item.DoDebe = item.DoDebe - objPagos.DeImporte;
                            objManejaVentas.ModificaVentas(item);
                        }
                    }
                }
            }
            //  LimpiarControles();
            // ActualizarControles();
            MessageBox.Show("El saldo se ha actualizado correctamente");
            this.Close();
        }