private void Guardarbutton_Click(object sender, EventArgs e)
        {
            NotasCredito Notas = LlenaClase();

            if (validar() == false)
            {
                return;
            }

            if (BuscartextBox.Text == string.Empty)
            {
                if (BLL.NotasCreditoBLL.Guardar(Notas))
                {
                    MessageBox.Show("Guardado!!");
                }
                else
                {
                    MessageBox.Show("No se pudo Guardar!");
                }
            }
            else
            {
                LimpiarProviderError();
                if (ErrorIDText() == false)
                {
                    return;
                }

                if (BLL.NotasCreditoBLL.Modificar(LlenaClase()))
                {
                    MessageBox.Show("Modificado!!");
                }
            }
        }
        public static bool Modificar(NotasCredito nota)
        {
            bool paso = false;

            try
            {
                Contex contex     = new Contex();
                var    estudiante = BLL.EstudiantesBLL.Buscar(nota.EstudianteID);
                var    notas      = Buscar(nota.NotasID);
                estudiante.Monto -= notas.Monto;
                BLL.EstudiantesBLL.Modificar(estudiante);

                contex.Entry(nota).State = EntityState.Modified;

                estudiante.Monto += nota.Monto;
                BLL.EstudiantesBLL.Modificar(estudiante);
                if (contex.SaveChanges() > 0)
                {
                    paso = true;
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(paso);
        }
        public static decimal CalcularMonto(decimal PCT, decimal Monto)
        {
            NotasCredito Nota = new NotasCredito();

            decimal pctbeca = 0, MontoFinal = 0;

            pctbeca = PCT / 100;

            MontoFinal = pctbeca * Monto;
            return(MontoFinal);
        }
        public static NotasCredito Buscar(int EstudianteId)
        {
            NotasCredito NotaCredito = new NotasCredito();

            try
            {
                Contex contex = new Contex();
                NotaCredito = contex.Notas.Find(EstudianteId);
            }
            catch (Exception)
            {
                throw;
            }

            return(NotaCredito);
        }
        private NotasCredito LlenaClase()
        {
            NotasCredito Nota = new NotasCredito();
            int          ID, IdEstudiante;

            decimal PCTBecaConvert = 0;

            int.TryParse(BuscartextBox.Text, out ID);
            int.TryParse(IDEstudiantetextBox.Text, out IdEstudiante);
            PCTBecaConvert       = BLL.NotasCreditoBLL.CalcularPCT(PCTnumericUpDown.Value);
            Nota.NotasID         = ID;
            Nota.Fecha           = FechadateTimePicker.Value;
            Nota.EstudianteID    = IdEstudiante;
            Nota.MontoAsignatura = MontoAsignaturanumericUpDown.Value;
            Nota.PctBeca         = PCTBecaConvert;
            Nota.Observaciones   = ObservacionestextBox.Text;
            Nota.Monto           = BLL.NotasCreditoBLL.CalcularMonto(PCTnumericUpDown.Value, MontoAsignaturanumericUpDown.Value);

            return(Nota);
        }
        public static bool Guardar(NotasCredito Notas)
        {
            bool paso = false;

            try
            {
                Contex Contex     = new Contex();
                var    estudiante = BLL.EstudiantesBLL.Buscar(Notas.EstudianteID);
                estudiante.Monto += Notas.Monto;
                BLL.EstudiantesBLL.Modificar(estudiante);
                Contex.Notas.Add(Notas);
                Contex.SaveChanges();
                paso = true;
            }
            catch (Exception)
            {
                throw;
            }
            return(paso);
        }
Exemplo n.º 7
0
        public NotasCredito BuscarNotacredito(DAConnectionSQL ObjDaConnexion, string TipoSerie)
        {
            NotasCredito notasCredito = new NotasCredito();


            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = ObjDaConnexion.Con;
            cmd.CommandText = "select MAX(Serie) as Serie, MAX(NUMERO) as Numero from NotaC_Join where serie = '" + SerieTienda + TipoSerie + "'";

            SqlDataReader dr = cmd.ExecuteReader();

            try
            {
                if (ObjDaConnexion.Con.State == ConnectionState.Closed)
                {
                    ObjDaConnexion.Open();
                }

                while (dr.Read())
                {
                    notasCredito.Serie  = dr.GetString(0);
                    notasCredito.Numero = dr.GetInt32(1);
                }

                dr.Close();
            }


            catch (Exception ex)
            {
                dr.Close();
                System.Windows.Forms.MessageBox.Show("Error" + ex.Message);
            }


            return(notasCredito);
        }
        private void Buscarbutton_Click(object sender, EventArgs e)
        {
            LimpiarProviderError();
            if (ErrorIDText() == false)
            {
                return;
            }
            int          ID;
            NotasCredito Nota        = new NotasCredito();
            Estudiantes  estudiantes = new Estudiantes();

            int.TryParse(BuscartextBox.Text, out ID);


            Nota = BLL.NotasCreditoBLL.Buscar(ID);

            if (Nota != null)
            {
                FechadateTimePicker.Value          = Nota.Fecha;
                IDEstudiantetextBox.Text           = Nota.EstudianteID.ToString();
                MontoAsignaturanumericUpDown.Value = Convert.ToDecimal(Nota.MontoAsignatura);
                PCTnumericUpDown.Value             = Nota.PctBeca;
                ObservacionestextBox.Text          = Nota.Observaciones;
                MontotextBox.Text = Nota.Monto.ToString();


                if (BLL.EstudiantesBLL.Buscar(Nota.EstudianteID) != null)
                {
                    estudiantes        = BLL.EstudiantesBLL.Buscar(Nota.EstudianteID);
                    NombretextBox.Text = estudiantes.Nombre;
                }
            }
            else
            {
                MessageBox.Show("Persona No encontada");
            }
        }
Exemplo n.º 9
0
        public NotasCredito InsertarNotasCredito(DAConnectionSQL ObjDaConnexion, ListaNotasCredito ObjListaNotasCredito, string TipoSerie, UserSistemas oUserSistemas)
        {
            string       StrinSQL     = "";
            Int32        NumNCR       = 0;
            NotasCredito notasCredito = new NotasCredito();

            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = ObjDaConnexion.Con;
            cmd.CommandType = CommandType.Text;

            //ExisteNC = ValidarDevolucion(cmd, ObjNotasCredito.Serie, ObjNotasCredito.Numero, ObjNotasCredito.CodBarra, ObjNotasCredito.UnidadesDevueltas);

            try
            {
                if (ObjDaConnexion.Con.State == ConnectionState.Closed)
                {
                    ObjDaConnexion.Open();
                }

                NumNCR = BuscarNumeroDoc(cmd, TipoSerie) + 1;

                cmd.Transaction = ObjDaConnexion.Tran;

                cmd.Transaction = ObjDaConnexion.Con.BeginTransaction();

                //ObjDaConnexion.BeginTransaction();

                foreach (var item in ObjListaNotasCredito)
                {
                    item.CodArticulo = BuscarCodigoArticulo(cmd, item.Referencia);


                    StrinSQL = "INSERT INTO NotaC_Join ";
                    StrinSQL = StrinSQL + "(Fecha_Notac,Serie,Numero,Referencia,Descripcion,UnidadesVenta,UnidadesDevueltas, ";
                    StrinSQL = StrinSQL + "RazonDevolucion,Precio,Talla,Color,CodBarra,Almacen,NumLinea,Dtco,CodArticulo, ";
                    StrinSQL = StrinSQL + "Precio_Sin_Iva, Fecha_Fact, Serie_Fact , Numero_Fact,CODVENDEDOR, Linea_Fact ) ";
                    StrinSQL = StrinSQL + "VALUES ('" + DateTime.Now.Date.ToString("MM/dd/yyyy") + "','" + SerieTienda + TipoSerie + "'," + NumNCR + ",";
                    StrinSQL = StrinSQL + "'" + item.Referencia + "','" + item.Descripcion + "',";
                    StrinSQL = StrinSQL + item.Unidades + "," + item.UnidadesDevueltas + ",'" + item.RazonDevolucion + "',";
                    StrinSQL = StrinSQL + item.Precio + ",'" + item.Talla + "','";
                    StrinSQL = StrinSQL + item.CodColor + "','" + item.CodBarra + "','" + Bodega + "'," + item.NumLinea + ",'";
                    StrinSQL = StrinSQL + item.Descuento + "'," + item.CodArticulo + "," + item.Precio_Sin_iva + ",'";
                    StrinSQL = StrinSQL + item.Fecha_Fact.Date.ToString("MM/dd/yyyy") + "','" + item.Serie_Fact + "', ";
                    StrinSQL = StrinSQL + item.Num_Fact + ",'" + oUserSistemas.CODVENDEDOR + "', '" + item.Linea_Fact + "')";

                    cmd.CommandText = StrinSQL;

                    cmd.ExecuteNonQuery();
                }


                StrinSQL        = "JOIN_NC_CAB";
                cmd.CommandText = StrinSQL;

                cmd.ExecuteNonQuery();

                cmd.CommandText = "select MAX(Serie) as Serie, MAX(NUMERO) as Numero from NotaC_Join where serie = '" + SerieTienda + TipoSerie + "'";

                SqlDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    notasCredito.Serie  = dr["Serie"].ToString();
                    notasCredito.Numero = Convert.ToInt32(dr["NUMERO"]);
                }

                dr.Close();
                //cmd.Transaction = ObjDaConnexion.Con.
                cmd.Transaction.Commit(); //= ObjDaConnexion.Tran.Commit();

                return(notasCredito);
                //exitoso = true;
            }
            catch (Exception ex)
            {
                cmd.Transaction.Rollback(); //ObjDaConnexion.RollBackTransaction();
                //dr.Close();

                System.Windows.Forms.MessageBox.Show("Error al ejecutar el Qyery " + ex.Message, "Información", MessageBoxButtons.OK, MessageBoxIcon.Error);;
            }

            //return exitoso;
            return(notasCredito);
        }
Exemplo n.º 10
0
        public ListaNotasCredito ValidarDevolucion(DAConnectionSQL ObjDaConnexion, string SerieDoc, Int32 NumeroDoc, string CodBar, int CantdadDev, int Linea_Fact)
        {
            ListaNotasCredito ObjListaNotasCredito = new ListaNotasCredito();
            bool existe = false;
            //var ConClass = new DAConnectionSQL();
            string     StrinSQL = "";
            SqlCommand cmd      = new SqlCommand();

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = ObjDaConnexion.Con;


            StrinSQL = "Select * ";
            StrinSQL = StrinSQL + " FROM NotaC_Join where Serie_Fact = '" + SerieDoc + "' and Numero_Fact = " + NumeroDoc + "  And ";
            StrinSQL = StrinSQL + "CodBarra = '" + CodBar + "' and Linea_Fact = ' " + Linea_Fact + "'";

            cmd.CommandText = StrinSQL;
            SqlDataReader dr = cmd.ExecuteReader();

            try
            {
                if (ObjDaConnexion.Con.State == ConnectionState.Closed)
                {
                    //ObjDaConnexion.Open();
                    cmd.Connection.Open();
                }


                while (dr.Read())
                {
                    NotasCredito ObjNotaCredito = new NotasCredito();
                    var          withBlock      = ObjNotaCredito;
                    if (dr[0] != DBNull.Value)
                    {
                        withBlock.FechaNC = DateTime.Parse(dr.GetDateTime(0).ToString());
                    }
                    withBlock.Serie             = dr.GetString(1);
                    withBlock.Numero            = dr.GetInt32(2);
                    withBlock.Referencia        = dr.GetString(3);
                    withBlock.Descripcion       = dr.GetString(4);
                    withBlock.Unidades          = dr.GetInt32(5);
                    withBlock.UnidadesDevueltas = dr.GetInt32(6);
                    withBlock.RazonDevolucion   = dr.GetString(7);
                    withBlock.Precio            = decimal.Parse(dr.GetDecimal(8).ToString());
                    withBlock.Talla             = dr.GetString(9).ToString();
                    withBlock.Color             = dr.GetString(10);
                    withBlock.CodBarra          = dr.GetString(11);
                    withBlock.Almacen           = dr.GetString(12);
                    if (dr[17] != DBNull.Value)
                    {
                        withBlock.FechaNC = DateTime.Parse(dr.GetDateTime(0).ToString());
                    }
                    //withBlock.Fecha_Fact = DateTime.Parse(dr.GetDateTime(17).ToString());
                    withBlock.Serie_Fact = dr.GetString(18);
                    withBlock.Num_Fact   = dr.GetInt32(19);

                    ObjListaNotasCredito.Add(ObjNotaCredito);
                }

                dr.Close();
            }
            catch (Exception ex)
            {
                dr.Close();
                System.Windows.Forms.MessageBox.Show("Error" + ex.Message);
            }


            return(ObjListaNotasCredito); //CodigoArticuloBD;
        }
Exemplo n.º 11
0
 public FrmPrintNCR(DAConnectionSQL ObjDAConnecion, NotasCredito oNotaCredito)
 {
     oProcNotaCredito = oNotaCredito;
     ObjDaConnexion   = ObjDAConnecion;
     InitializeComponent();
 }
Exemplo n.º 12
0
        private NotasCredito BusarUlimaNotaCredito()
        {
            NotasCredito UltimaNotaCredito = ObjProcDB.BuscarNotacredito(ObjDaConnexion, TipoSerie);

            return(UltimaNotaCredito);
        }
Exemplo n.º 13
0
        private void BtnProcesar_Click(object sender, EventArgs e)
        {
            bool         Exitoso             = false;
            string       SerieFacDocumento   = "";
            string       SerieFacActual      = "";
            Int32        NumDocDocument      = 0;
            Int32        NumDocActual        = 0;
            int          NumLinea            = 1;
            NotasCredito ObjNotaCreditoProc2 = new NotasCredito();

            this.Cursor = Cursors.WaitCursor;

            foreach (DataGridViewRow Row in Dgv_ProductosDev.Rows)
            {
                String strFila = Row.Index.ToString();
                //ListaNotasCredito ObjListaNCR = new ListaNotasCredito();
                NotasCredito ObjNotaCredito = new NotasCredito();

                SerieFacDocumento = Row.Cells[0].Value.ToString();
                NumDocDocument    = int.Parse(Row.Cells[1].Value.ToString());

                if (SerieFacDocumento == SerieFacActual && NumDocDocument == NumDocActual)
                {
                    NumLinea = NumLinea + 1;
                }
                else
                {
                    NumLinea = 1;
                }

                if (SerieFacActual != "" && NumDocActual != 0 && NumDocDocument != NumDocActual)
                {
                    //Procesa Nota de Credito
                    NotasCredito ObjNotaCreditoProc = new NotasCredito();
                    //Exitoso = ObjProcDB.EjecutarNotasCredito(ObjDaConnexion);

                    this.Cursor        = Cursors.WaitCursor;
                    ObjNotaCreditoProc = ObjProcDB.InsertarNotasCredito(ObjDaConnexion, ObjListaNotasCredito, TipoSerie, oUserSistemasLog);

                    ObjListaNotasCredito.Clear();

                    //ValidarProceso(Exitoso, SerieFacDocumento, NumDocDocument, NumLinea);

                    //ObjNotaCredit = BusarUlimaNotaCredito();
                    if (ObjNotaCreditoProc.Numero != 0)
                    {
                        ObjBuildXml.ContruyeXML(ObjNotaCreditoProc.Serie, ObjNotaCreditoProc.Numero);

                        Process.Start(RutaExeFirmado + "llamarEXE.exe");

                        var stopwatch = Stopwatch.StartNew();
                        Thread.Sleep(8000); //tiempo de pausa
                        stopwatch.Stop();

                        FrmPrintNCR MyFormPrintNCR = new FrmPrintNCR(ObjDaConnexion, ObjNotaCreditoProc);   //(ObjListaNCR);
                        MyFormPrintNCR.Show();
                        this.Show();


                        MessageBox.Show("La Devolución de la Factura " + SerieFacDocumento + " - " +
                                        NumDocDocument + " se Proceso correctamente",
                                        "Información", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        MessageBox.Show("La Devoluci+on de la Factura " + SerieFacDocumento + " - " +
                                        NumDocDocument + " No se Proceso correctamente",
                                        "Información", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                ObjNotaCredito.Serie  = TipoSerie;
                ObjNotaCredito.Numero = 0;

                ObjNotaCredito.Fecha_Fact = DateTime.Parse(Row.Cells[2].Value.ToString());
                ObjNotaCredito.Serie_Fact = Row.Cells[0].Value.ToString();
                ObjNotaCredito.Num_Fact   = Int32.Parse(Row.Cells[1].Value.ToString());

                ObjNotaCredito.Referencia        = Row.Cells[3].Value.ToString();
                ObjNotaCredito.Descripcion       = Row.Cells[4].Value.ToString();
                ObjNotaCredito.Unidades          = Int32.Parse(Row.Cells[5].Value.ToString());
                ObjNotaCredito.UnidadesDevueltas = Int32.Parse(Row.Cells[6].Value.ToString());
                ObjNotaCredito.RazonDevolucion   = Row.Cells[7].Value.ToString();
                ObjNotaCredito.Precio            = decimal.Parse(Row.Cells[8].Value.ToString());
                ObjNotaCredito.Almacen           = Row.Cells[9].Value.ToString();
                ObjNotaCredito.Talla             = Row.Cells[10].Value.ToString();
                ObjNotaCredito.Color             = Row.Cells[11].Value.ToString();
                ObjNotaCredito.CodBarra          = Row.Cells[13].Value.ToString();
                ObjNotaCredito.CodColor          = Row.Cells[14].Value.ToString();
                ObjNotaCredito.NumLinea          = NumLinea;
                ObjNotaCredito.Total             = ObjNotaCredito.UnidadesDevueltas * ObjNotaCredito.Precio;
                ObjNotaCredito.Linea_Fact        = Int32.Parse(Row.Cells[15].Value.ToString());


                SerieFacActual = SerieFacDocumento;
                NumDocActual   = NumDocDocument;


                //ObjListaNCR = ObjProcDB.ValidarDevolucion(ObjNotaCredito.Serie, ObjNotaCredito.Numero, ObjNotaCredito.CodBarra, ObjNotaCredito.UnidadesDevueltas)

                ObjListaNotasCredito.Add(ObjNotaCredito);
            }
            ObjListaProductosDev.Clear();
            Dgv_ProductosDev.DataSource = null;
            Dgv_ProductosDev.Refresh();

            MessageBox.Show("Proceso Completado Correctamente ", "Información", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

            //Exitoso = ObjProcDB.EjecutarNotasCredito(ObjDaConnexion);
            this.Cursor         = Cursors.WaitCursor;
            ObjNotaCreditoProc2 = ObjProcDB.InsertarNotasCredito(ObjDaConnexion, ObjListaNotasCredito, TipoSerie, oUserSistemasLog);
            ObjListaNotasCredito.Clear();

            //ObjNotaCredit = BusarUlimaNotaCredito();

            ObjBuildXml.ContruyeXML(ObjNotaCreditoProc2.Serie, ObjNotaCreditoProc2.Numero);
            try
            {
                Process.Start(RutaExeFirmado + "llamarEXE.exe");

                MessageBox.Show("Firmado de la Devolución de la Factura " +
                                SerieFacActual + " - " + NumDocDocument +
                                " Procesada Correctamente ", "Información", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                var stopwatch = Stopwatch.StartNew();
                Thread.Sleep(8000);     //tiempo de pausa
                stopwatch.Stop();

                FrmPrintNCR MyFormPrintNCR = new FrmPrintNCR(ObjDaConnexion, ObjNotaCreditoProc2);       //(ObjListaNCR);
                MyFormPrintNCR.Show();
                this.Show();

                this.Cursor = Cursors.Default;
            }

            catch (Exception)
            {
                MessageBox.Show("Error al Procesar el Firmado de " + NumLinea + " de la Devolucion de la Factura " +
                                SerieFacActual + " " + NumDocDocument
                                , "Información", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 14
0
        public bool ValidarDevolucion(ProductoDev OProductosDevNCR, int TotalDevoluciones)
        {
            bool Procesar         = false;
            int  TotalProducXProc = (from DevxProcesar in ObjListaProductosDev select DevxProcesar.UnidadesDevueltas).Sum();

            if (TotalDevoluciones > OProductosDevNCR.UnidadesVenta)  //ObjListaNCR[0].Unidades)
            {
                var result = MessageBox.Show("El Artículo " + OProductosDevNCR.CodBarra + " de la Factura " + OProductosDevNCR.Serie + " " + OProductosDevNCR.Numero +
                                             " Posee Devoluciones Previas " + "\r\n" +
                                             " Desea Verificar Devoluciones?", "Información", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.Yes)
                {
                    ListaNotasCredito ObjListaNCR = new ListaNotasCredito();
                    ObjListaNCR = ObjProcDB.ValidarDevolucion(ObjDaConnexion, OProductosDevNCR.Serie, OProductosDevNCR.Numero,
                                                              OProductosDevNCR.CodBarra, OProductosDevNCR.UnidadesDevueltas, OProductosDevNCR.Linea_Fact);
                    ConsultaDevolucion v1 = new ConsultaDevolucion(ObjListaNCR);
                    this.Hide();
                    v1.ShowDialog();
                    this.Show();
                }
                else
                {
                    MessageBox.Show("No se pueden Devolver más unidades de las vendidas en esta Factura " + "\r\n"
                                    , "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else if (TotalDevoluciones + TotalProducXProc > OProductosDevNCR.UnidadesVenta)
            {
                MessageBox.Show("No se puede devolver mas de lo permitido, Solo Puede Procesar lo Pendiente " + "\r\n"
                                , "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }


            else
            {
                NotasCredito ObjNCR = new NotasCredito();

                ObjNCR.Almacen     = OProductosDevNCR.Almacen;
                ObjNCR.CodArticulo = OProductosDevNCR.CodArticulo;
                ObjNCR.CodBarra    = OProductosDevNCR.CodBarra;
                ObjNCR.CodColor    = OProductosDevNCR.CodColor;
                ObjNCR.Color       = OProductosDevNCR.Color;
                ObjNCR.Descripcion = OProductosDevNCR.Descripcion;
                ObjNCR.Fecha_Fact  = OProductosDevNCR.Fecha_Factura;
                ObjNCR.Num_Fact    = OProductosDevNCR.Numero;
                ObjNCR.Precio      = OProductosDevNCR.Precio;
                //ObjNCR. = OProductosDevNCR. ;

                ObjListaNotasCredito.Add(ObjNCR);
                Procesar = true;
            }

            //var result2 = MessageBox.Show("Se va a procesar la Devolución? " + "\r\n"
            //, "Información", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            //if (result2 == DialogResult.Yes)
            //{

            //}

            return(Procesar);
        }