Exemplo n.º 1
0
        public Int32 InsertPago(E_Pago ObjPago)
        {
            Int32        PagoID    = 0;
            SqlDatabase  SqlClient = new SqlDatabase(connectionString);
            DbConnection tCnn;

            tCnn = SqlClient.CreateConnection();
            tCnn.Open();
            DbTransaction tran = tCnn.BeginTransaction();

            try
            {
                DbCommand SqlCommand = SqlClient.GetStoredProcCommand("Ventas.Usp_Insert_PagoNavideño");
                SqlClient.AddInParameter(SqlCommand, "@NumComprobante", SqlDbType.Char, ObjPago.NumComprobante);
                SqlClient.AddInParameter(SqlCommand, "@TipoComprobante", SqlDbType.Int, ObjPago.TipoComprobanteID);
                SqlClient.AddInParameter(SqlCommand, "@Importe", SqlDbType.Decimal, ObjPago.Importe);
                SqlClient.AddInParameter(SqlCommand, "@FormaPago", SqlDbType.Int, ObjPago.FormaPagoID);
                SqlClient.AddInParameter(SqlCommand, "@UsuarioID", SqlDbType.Int, ObjPago.UsuarioID);

                PagoID = Convert.ToInt32(SqlClient.ExecuteScalar(SqlCommand, tran));
                SqlCommand.Dispose();

                tran.Commit();
                tCnn.Close();
                tCnn.Dispose();

                return(PagoID);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw new Exception(ex.Message);
            }
        }
Exemplo n.º 2
0
        public Int32 InsertPago(E_Pago ObjPago, E_NotaIngreso ObjNotaIngreso, int EstadoID)
        {
            Int32 NotaIngresoID = 0;

            try
            {
                SqlDatabase SqlClient  = new SqlDatabase(connectionString);
                DbCommand   SqlCommand = SqlClient.GetStoredProcCommand("Ventas.Usp_InsertPago2");

                SqlClient.AddInParameter(SqlCommand, "@EmpresaID", SqlDbType.Char, ObjNotaIngreso.EmpresaID);
                SqlClient.AddInParameter(SqlCommand, "@FormaPagoID", SqlDbType.TinyInt, ObjPago.FormaPagoID);
                SqlClient.AddInParameter(SqlCommand, "@Tipo", SqlDbType.Char, ObjNotaIngreso.Tipo);
                SqlClient.AddInParameter(SqlCommand, "@Numcaja", SqlDbType.Int, ObjNotaIngreso.Numcaja);
                SqlClient.AddInParameter(SqlCommand, "@Observacion", SqlDbType.VarChar, ObjNotaIngreso.Observacion);
                SqlClient.AddInParameter(SqlCommand, "@NumComprobante", SqlDbType.Char, ObjPago.NumComprobante);
                SqlClient.AddInParameter(SqlCommand, "@TipoComprobanteID", SqlDbType.TinyInt, ObjPago.TipoComprobanteID);
                SqlClient.AddInParameter(SqlCommand, "@LugarPago", SqlDbType.Char, ObjNotaIngreso.LugarPago);
                SqlClient.AddInParameter(SqlCommand, "@Importe", SqlDbType.Decimal, ObjPago.Importe);
                SqlClient.AddInParameter(SqlCommand, "@ClienteID", SqlDbType.Int, ObjNotaIngreso.ClienteID);
                SqlClient.AddInParameter(SqlCommand, "@Estado", SqlDbType.TinyInt, ObjNotaIngreso.Estado);
                SqlClient.AddInParameter(SqlCommand, "@UsuarioID", SqlDbType.Int, ObjPago.UsuarioID);

                SqlClient.AddInParameter(SqlCommand, "@EstadoID", SqlDbType.Int, EstadoID);

                SqlClient.AddInParameter(SqlCommand, "@Serie", SqlDbType.Char, ObjNotaIngreso.Serie);
                SqlClient.AddInParameter(SqlCommand, "@Numero", SqlDbType.Char, ObjNotaIngreso.Numero);

                NotaIngresoID = Convert.ToInt32(SqlClient.ExecuteScalar(SqlCommand));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return(NotaIngresoID);
        }
Exemplo n.º 3
0
        private void BtnIngresar_Click(object sender, EventArgs e)
        {
            ErrProvider.Clear();
            try
            {
                if (TxtCantidad.Text != "" & TxtConcepto.Text != "")
                {
                    //inserta un ingreso a la caja

                    //llenar el objPago
                    E_Pago ObjE_Pago = new E_Pago();
                    ObjE_Pago.PagoID            = 0;
                    ObjE_Pago.NumComprobante    = "";
                    ObjE_Pago.TipoComprobanteID = 0;
                    ObjE_Pago.Importe           = Convert.ToDecimal(TxtCantidad.Text);
                    ObjE_Pago.FormaPagoID       = 2;//contado
                    ObjE_Pago.UsuarioID         = AppSettings.UserID;


                    //llenar la nota de ingreso
                    E_NotaIngreso ObjE_NotaIngreso = new E_NotaIngreso();
                    ObjE_NotaIngreso.Tipo        = "E";//es salida
                    ObjE_NotaIngreso.Numcaja     = NumCaja;
                    ObjE_NotaIngreso.EmpresaID   = EmpresaID;
                    ObjE_NotaIngreso.Observacion = "Inicio dia";
                    ObjE_NotaIngreso.LugarPago   = AppSettings.SedeID;

                    if (AppSettings.ImpresoraPago != "")
                    {
                        Int32 NotaIngresoID = 0;
                        NotaIngresoID = ObjCL_Pago.InsertPago(ObjE_Pago, ObjE_NotaIngreso, 12);

                        printDocument1.PrinterSettings.PrinterName = AppSettings.ImpresoraPago;
                        printDocument1.Print();
                        MessageBox.Show("Se registro correctamente la salida de caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("no se ha seleccionado la impresora de pago, no se imprimira el Egreso", "", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
                else
                {
                    if (TxtCantidad.Text == "")
                    {
                        ErrProvider.SetError(TxtCantidad, "Debe ingresar una cantidad valida.");
                    }
                    if (TxtConcepto.Text == "")
                    {
                        ErrProvider.SetError(TxtConcepto, "Debe ingresar el concepto del egreso.");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\rMetodo Ingresar inicio caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        public Int32 InsertPago(E_Pago ObjPago, E_NotaIngreso ObjNotaIngreso, int EstadoID)
        {
            CD_Pago objCD_Pago    = new CD_Pago(AppSettings.GetConnectionString);
            Int32   NotaIngresoID = 0;

            NotaIngresoID = objCD_Pago.InsertPago(ObjPago, ObjNotaIngreso, EstadoID);
            return(NotaIngresoID);
        }
Exemplo n.º 5
0
        public Int32 InsertPago(E_Pago ObjPago)
        {
            Int32   PagoID     = 0;
            CD_Pago objCD_Pago = new CD_Pago(AppSettings.GetConnectionString);

            PagoID = objCD_Pago.InsertPago(ObjPago);
            return(PagoID);
        }
Exemplo n.º 6
0
        private void BtnIngresar_Click(object sender, EventArgs e)
        {
            try
            {
                ErrProvider.Clear();
                if (TxtCantidad.Text != "")
                {
                    //inserta un ingreso a la caja

                    //llenar el objPago
                    E_Pago ObjE_Pago = new E_Pago();
                    ObjE_Pago.PagoID            = 0;
                    ObjE_Pago.NumComprobante    = "";
                    ObjE_Pago.TipoComprobanteID = 0;
                    ObjE_Pago.Importe           = Convert.ToDecimal(TxtCantidad.Text);
                    ObjE_Pago.FormaPagoID       = 2;//contado
                    ObjE_Pago.UsuarioID         = AppSettings.UserID;


                    //llenar la nota de ingreso
                    E_NotaIngreso ObjE_NotaIngreso = new E_NotaIngreso();
                    ObjE_NotaIngreso.Tipo        = "C";
                    ObjE_NotaIngreso.Numcaja     = NumCaja;
                    ObjE_NotaIngreso.EmpresaID   = EmpresaID;
                    ObjE_NotaIngreso.Observacion = "Inicio dia";
                    ObjE_NotaIngreso.LugarPago   = AppSettings.SedeID;

                    NotaIngresoID = ObjCL_Pago.InsertPago(ObjE_Pago, ObjE_NotaIngreso, 12);
                    MessageBox.Show("Se registro correctamente El ingreso de caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    ErrProvider.SetError(TxtCantidad, "Ingrese una cantidad valida.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\rMetodo Ingresar inicio caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
        private void BtnRegistrar_Click(object sender, EventArgs e)
        {
            ErrProvider.Clear();
            try
            {
                if (TxtImporte.Text != "" & TxtConcepto.Text != "")
                {
                    if (ClienteID == 0 | ClienteID == 1 | ClienteID == 204 | ClienteID == 241 | ClienteID == 3032)
                    {
                        MessageBox.Show("Debe exigir datos que identifiquen al cliente\nNo puede ser uno generico (Clientes varios)", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    //inserta un ingreso a la caja

                    //llenar el objPagos
                    E_Pago ObjE_Pago = new E_Pago();
                    ObjE_Pago.PagoID            = 0;
                    ObjE_Pago.NumComprobante    = "";
                    ObjE_Pago.TipoComprobanteID = 0;
                    ObjE_Pago.Importe           = Convert.ToDecimal(TxtImporte.Text);
                    ObjE_Pago.FormaPagoID       = 2;//contado
                    ObjE_Pago.UsuarioID         = AppSettings.UserID;


                    //llenar la nota de ingreso
                    E_NotaIngreso ObjE_NotaIngreso = new E_NotaIngreso();
                    ObjE_NotaIngreso.Tipo        = "A";//es Adelanto
                    ObjE_NotaIngreso.Numcaja     = NumCaja;
                    ObjE_NotaIngreso.EmpresaID   = EmpresaID;
                    ObjE_NotaIngreso.Observacion = TxtConcepto.Text;
                    ObjE_NotaIngreso.LugarPago   = AppSettings.SedeID;
                    ObjE_NotaIngreso.ClienteID   = ClienteID;
                    ObjE_NotaIngreso.Estado      = 0;

                    DataView DV = new DataView(UTI_Datatables.Dt_Configuracion, "Codigo ='IMP_PA'", "", DataViewRowState.CurrentRows);

                    if (DV.Count > 0)
                    {
                        NotaIngresoID = ObjCL_Pago.InsertPago(ObjE_Pago, ObjE_NotaIngreso, 12);

                        printDocument1.PrinterSettings.PrinterName = DV[0]["Data"].ToString();
                        printDocument1.Print();
                        MessageBox.Show("Se registro correctamente el adelanto", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("no se ha seleccionado la impresora de pago, no se imprimira el adelanto", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                }
                else
                {
                    if (TxtImporte.Text == "")
                    {
                        ErrProvider.SetError(TxtImporte, "Debe ingresar una cantidad valida.");
                    }
                    if (TxtConcepto.Text == "")
                    {
                        ErrProvider.SetError(TxtConcepto, "Debe ingresar el concepto del adelanto.");
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\rMetodo Ingresar adelanto", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor = Cursors.WaitCursor;
                errValidar.Clear();

                if (CboTipoComprobante.SelectedValue == null)
                {
                    errValidar.SetError(CboTipoComprobante, "Seleccione el Comprobante");
                    validarCheck = true;
                }
                else
                {
                    //if (CboTipoComprobante.SelectedValue.ToString().Equals("1"))
                    //    printDocument1.PrinterSettings.PrinterName = ImpresoraBoletaGranja;
                    //else if (CboTipoComprobante.SelectedValue.ToString().Equals("1"))
                    //    printDocument1.PrinterSettings.PrinterName = ImpresoraFacturaGranja;
                    //else if (CboTipoComprobante.SelectedValue.ToString().Equals("3"))
                    //    printDocument1.PrinterSettings.PrinterName = ImpresoraTicketGranja;

                    string EMPRESA_ID       = "GH";
                    string TIPO_COMPROBANTE = "";
                    if (Convert.ToInt16(CboTipoComprobante.SelectedValue) == 1)
                    {
                        TIPO_COMPROBANTE = "BO";
                    }
                    else if (Convert.ToInt16(CboTipoComprobante.SelectedValue) == 2)
                    {
                        TIPO_COMPROBANTE = "FA";
                    }
                    else if (Convert.ToInt16(CboTipoComprobante.SelectedValue) == 3)
                    {
                        TIPO_COMPROBANTE = "TI";
                    }
                    //ahora se gauradara en una tabla Configuracion.Configuracion

                    DataView DV = new DataView(UTI_Datatables.Dt_Configuracion, "Codigo ='" + "IMP_" + EMPRESA_ID + "_" + TIPO_COMPROBANTE + "'", "", DataViewRowState.CurrentRows);

                    if (DV.Count > 0)
                    {
                        printDocument1.PrinterSettings.PrinterName = DV[0]["Data"].ToString();
                    }
                    else
                    {
                        MessageBox.Show("No existe una impresora configurada, por favor agregela", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }


                    if (printDocument1.PrinterSettings.PrinterName == "")
                    {
                        MessageBox.Show("Al parecer no se ha seleccionado la impresora. no se imprimira el comprobante.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        Cursor = Cursors.Default;
                        return;
                    }
                }


                if (cbSerie.SelectedValue == null)
                {
                    errValidar.SetError(cbSerie, "Seleccione la serie"); validarCheck = true;
                }
                if (NumCaja == 0)
                {
                    errValidar.SetError(LblCaja, "Seleccione la caja");
                    validarCheck = true;
                }
                if (cbTipoPago.SelectedValue == null)
                {
                    errValidar.SetError(cbTipoPago, "Seleccione el tipo de pago");
                    validarCheck = true;
                }
                else if (cbFormaPago.SelectedValue == null && cbTipoPago.SelectedValue.ToString() != "1")
                {
                    errValidar.SetError(cbFormaPago, "Seleccione la forma de pago");
                    validarCheck = true;
                }

                if (validarCheck == true)
                {
                    Cursor       = Cursors.Default;
                    validarCheck = false;
                    return;
                }


                if (cbTipoPago.SelectedValue.ToString().Equals("1"))
                {
                    estadoID = (int)Enums.Comprobante.Pendiente;
                }
                else
                {
                    estadoID = (int)Enums.Comprobante.Pagado;
                }

                if (cbFormaPago.SelectedValue == null)
                {
                    formaPago = null;
                }
                else
                {
                    formaPago = Convert.ToInt32(cbFormaPago.SelectedValue);
                }

                E_Comprobante ObjComprobante = new E_Comprobante();
                E_Pago        ObjPago        = new E_Pago();

                ObjComprobante.EmpresaID         = AppSettings.EmpresaID;
                ObjComprobante.SedeID            = AppSettings.SedeID;
                ObjComprobante.TipoComprobanteID = Convert.ToInt32(CboTipoComprobante.SelectedValue);
                ObjComprobante.ClienteID         = ClienteID;
                ObjComprobante.Direccion         = lblDireccion.Text;
                ObjComprobante.TipoVentaID       = 1;
                ObjComprobante.TipoPagoId        = Convert.ToInt32(cbTipoPago.SelectedValue);
                ObjComprobante.FormaPagoID       = formaPago;
                ObjComprobante.NumCaja           = NumCaja;
                ObjComprobante.IGV      = IGV;
                ObjComprobante.SubTotal = subTotal;
                ObjComprobante.TotIgv   = TotalIGV;
                ObjComprobante.Vendedor = VendedorID;
                ObjComprobante.Cajero   = AppSettings.UserID;
                ObjComprobante.Serie    = cbSerie.Text;
                ObjComprobante.EstadoID = estadoID;
                ObjComprobante.Externa  = chkExterno.Checked;
                ObjComprobante.Vale     = vale;
                ObjComprobante.NumVale  = NumVale;


                //es provisional
                DataTable dt = new DataTable();
                dt              = new CL_Comprobante().InsertComprobante(ObjComprobante, dsPedido.Tables["detallePedido"], NumPedido, "N", DtValesConsumo, DtBoucher, dt);
                NumComprobante  = dt.Rows[0]["NumComprobante"].ToString();
                FECHA_IMPRESION = Convert.ToDateTime(dt.Rows[0]["FECHA_ACTUAL"].ToString());
                DtValesConsumo.Rows.Clear(); // limpiar los vales
                DtBoucher.Rows.Clear();      // limpiar los boucher

                printDocument1.Print();

                /*if (ObjComprobante.TipoPagoId == 2)
                 * {
                 *
                 *  ObjPago.NumComprobante = NumComprobante;
                 *  ObjPago.TipoComprobanteID = ObjComprobante.TipoComprobanteID;
                 *  ObjPago.Importe = Total;
                 *  ObjPago.FormaPagoID = ObjComprobante.FormaPagoID;
                 *  ObjPago.UsuarioID = ObjComprobante.Cajero;
                 *
                 *  new CL_Pago().InsertPago(ObjPago);
                 *
                 *  FrmPago ObjFrmPago = new FrmPago();
                 *  ObjFrmPago.TotalPagar = Convert.ToDecimal(Total);
                 *  ObjFrmPago.ShowDialog();
                 * }*/

                if (AppSettings.SedeID != "001VU")
                {
                    new CL_Helper().SendMail("VALES DE NAVIDAD", string.Concat("IMPRIMIR LOS VALES ESTE COMPROBANTE : ", NumComprobante), "*****@*****.**");
                }

                MessageBox.Show("El comprobante se generó correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Limpiar();
                validarCheck = false;

                Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                Cursor = Cursors.Default;
            }
        }
Exemplo n.º 9
0
        private void BtnPagar_Click(object sender, EventArgs e)
        {
            try
            {
                ErrProvider.Clear();
                string NumComprobante    = "";
                Int32  TipoComprobanteID = 0;

                decimal Pagar = 0;
                if (TxtPagar.Text != "" & TxtPagar.Text != ".")
                {
                    Pagar = Convert.ToDecimal(TxtPagar.Text);
                }

                if (RbCampanha.Checked == true & LstComprobantes.ListCount > 0)
                {
                    NumComprobante    = LstComprobantes.Columns["NumComprobante"].Value.ToString();
                    TipoComprobanteID = Convert.ToInt32(LstComprobantes.Columns["TipoComprobanteID"].Value);
                }
                else if (RbComprobante.Checked == true & cbComprobante.SelectedIndex != -1 & c1cboCia.SelectedIndex != -1 & TxtComprobante.Text != "")
                {
                    NumComprobante    = c1cboCia.SelectedValue.ToString() + TxtComprobante.Text;
                    TipoComprobanteID = Convert.ToInt32(cbComprobante.Columns["TipoComprobanteID"].Value);
                }

                if (cbFormaPago.SelectedIndex != -1 & Pagar > 0 & NumComprobante != "" & TipoComprobanteID != 0 & PorPagarComprobante > 0 & PorPagarComprobante >= Pagar & NumCaja != 0)
                {
                    if (MessageBox.Show("¿Seguro que desea registrar el pago?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        //obtener datos de la empresa
                        DataView DV        = new DataView(DtEmpresas);
                        string   EmpresaID = NumComprobante.Substring(0, 2);
                        DV.RowFilter = "EmpresaID = '" + EmpresaID + "'";
                        string NomEmpresa = DV[0]["NomEmpresa"].ToString();
                        string RUC        = DV[0]["RUC"].ToString();

                        //llenar el objPago
                        E_Pago ObjE_Pago = new E_Pago();
                        ObjE_Pago.PagoID            = 0;
                        ObjE_Pago.NumComprobante    = NumComprobante;
                        ObjE_Pago.TipoComprobanteID = TipoComprobanteID;
                        ObjE_Pago.Importe           = Convert.ToDecimal(TxtPagar.Text);
                        ObjE_Pago.FormaPagoID       = Convert.ToInt32(cbFormaPago.SelectedValue);
                        ObjE_Pago.UsuarioID         = AppSettings.UserID;

                        //llenar la nota de ingreso
                        E_NotaIngreso ObjE_NotaIngreso = new E_NotaIngreso();
                        ObjE_NotaIngreso.Tipo        = "I";
                        ObjE_NotaIngreso.Numcaja     = NumCaja;
                        ObjE_NotaIngreso.EmpresaID   = AppSettings.EmpresaID;
                        ObjE_NotaIngreso.Observacion = TxtObservacion.Text;
                        ObjE_NotaIngreso.LugarPago   = AppSettings.SedeID;

                        //calcular el estado del comporbante
                        if (PorPagarComprobante > Pagar)    //todavia resta
                        {
                            EstadoID = 13;
                        }
                        else if (PorPagarComprobante == Pagar)    //es el total de la deuda del comprobante
                        {
                            EstadoID = 12;
                        }

                        Int32 CreditoID = 0;

                        if (RbCampanha.Checked == true)
                        {
                            CreditoID = Convert.ToInt32(LstCreditos.Columns["CreditoID"].Value);
                        }

                        printDocument1.PrinterSettings.PrinterName = ImpresoraPago;

                        //validar la impresion
                        if (ChkImprimir.Checked == true)
                        {
                            if (printDocument1.PrinterSettings.PrinterName != "")
                            {
                                FormatoImpresion = ObjCL_Pago.FormatoTicketPago(NomEmpresa, CreditoID, LstCreditos.Columns["NomCampanha"].Value.ToString(), AppSettings.NomSede, RUC, AppSettings.Usuario, Convert.ToDecimal(TxtPagar.Text), NomCaja);
                                //MessageBox.Show(FormatoImpresion, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                Int32 NotaIngresoID = 0;
                                NotaIngresoID = ObjCL_Pago.InsertPago(ObjE_Pago, ObjE_NotaIngreso, EstadoID);
                                MessageBox.Show("Se registro correctamente el pago", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);


                                printDocument1.Print();
                                LimpiarTodo();
                            }
                            else
                            {
                                MessageBox.Show("Debe seleccionar una impresora valida. no se guardara el pago.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            FormatoImpresion = ObjCL_Pago.FormatoTicketPago(NomEmpresa, CreditoID, LstCreditos.Columns["NomCampanha"].Value.ToString(), AppSettings.NomSede, RUC, AppSettings.Usuario, Convert.ToDecimal(TxtPagar.Text), NomCaja);


                            Int32 NotaIngresoID = 0;
                            NotaIngresoID = ObjCL_Pago.InsertPago(ObjE_Pago, ObjE_NotaIngreso, EstadoID);
                            MessageBox.Show("Se registro correctamente el pago", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);

                            MessageBox.Show(FormatoImpresion, "Formato", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            LimpiarTodo();
                        }
                    }
                }
                else
                {
                    if (NumCaja == 0)
                    {
                        ErrProvider.SetError(LblCaja, "Debe seleccionar una caja");
                    }
                    if (cbFormaPago.SelectedIndex == -1)
                    {
                        ErrProvider.SetError(cbFormaPago, "Debe seleccionar un tipo de pago");
                    }
                    if (TxtPagar.Text == "" | TxtPagar.Text == ".")
                    {
                        ErrProvider.SetError(TxtPagar, "Debe ingresar un pago válido");
                    }
                    if (Pagar > PorPagarComprobante)
                    {
                        MessageBox.Show("Ha ingresado un pago mayor a la deuda", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }

                /*else if (Pagar == 0)
                 *  MessageBox.Show("No ha ingresado el monto a pagar", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 * else if (PorPagarComprobante == 0)
                 *  MessageBox.Show("El comprobante ya esta pagado o no existe o no ha sido consultado todavia", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);}
                 * */
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 10
0
        private void BtnIngresar_Click(object sender, EventArgs e)
        {
            ErrProvider.Clear();
            try
            {
                if (TxtCantidad.Text != "" & TxtConcepto.Text != "" & TxtSerie.Text != "" & TxtNumero.Text != "")
                {
                    //inserta un ingreso a la caja

                    //llenar el objPago
                    E_Pago ObjE_Pago = new E_Pago();
                    ObjE_Pago.PagoID            = 0;
                    ObjE_Pago.NumComprobante    = "";
                    ObjE_Pago.TipoComprobanteID = 0;
                    ObjE_Pago.Importe           = Convert.ToDecimal(TxtCantidad.Text);
                    ObjE_Pago.FormaPagoID       = 2;//contado
                    ObjE_Pago.UsuarioID         = AppSettings.UserID;


                    //llenar la nota de ingreso
                    E_NotaIngreso ObjE_NotaIngreso = new E_NotaIngreso();
                    ObjE_NotaIngreso.Tipo        = "E";//es salida
                    ObjE_NotaIngreso.Numcaja     = NumCaja;
                    ObjE_NotaIngreso.EmpresaID   = EmpresaID;
                    ObjE_NotaIngreso.Observacion = TxtConcepto.Text;
                    ObjE_NotaIngreso.LugarPago   = AppSettings.SedeID;
                    ObjE_NotaIngreso.Serie       = TxtSerie.Text;
                    ObjE_NotaIngreso.Numero      = TxtNumero.Text;


                    DataView DV = new DataView(UTI_Datatables.Dt_Configuracion, "Codigo ='IMP_PA'", "", DataViewRowState.CurrentRows);

                    if (DV.Count > 0)
                    {
                        NotaIngresoID = ObjCL_Pago.InsertPago(ObjE_Pago, ObjE_NotaIngreso, 12);

                        printDocument1.PrinterSettings.PrinterName = DV[0]["Data"].ToString();
                        printDocument1.Print();
                        MessageBox.Show("Se registro correctamente la salida de caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("no se ha seleccionado la impresora de pago, no se imprimira el Egreso", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        return;
                    }
                }
                else
                {
                    if (TxtCantidad.Text == "")
                    {
                        ErrProvider.SetError(TxtCantidad, "Debe ingresar una cantidad valida.");
                    }
                    if (TxtConcepto.Text == "")
                    {
                        ErrProvider.SetError(TxtConcepto, "Debe ingresar el concepto del egreso.");
                    }
                    if (TxtSerie.Text == "" | TxtSerie.Text == "000")
                    {
                        ErrProvider.SetError(TxtSerie, "Ingrese una serie correcta.");
                    }
                    if (TxtNumero.Text == "" | TxtNumero.Text == "0000000")
                    {
                        ErrProvider.SetError(TxtNumero, "Ingrese un número correcto.");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\r\rMetodo Ingresar inicio caja", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }