Example #1
0
 public ConsultaDevolucion(ListaNotasCredito ObjListaNCR)
 {
     ObjListaNotasCredito = ObjListaNCR;
     InitializeComponent();
 }
Example #2
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);
        }
Example #3
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);
        }
Example #4
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;
        }
Example #5
0
        private void dgv_Doc_DoubleClick(object sender, EventArgs e)
        {
            string            RutaImagen;
            ListaNotasCredito ObjListaNCR    = new ListaNotasCredito();
            ProductoDev       ObjProductoDev = new ProductoDev();

            ObjProductoDev.Serie         = this.dgv_Doc.CurrentRow.Cells[0].Value.ToString();
            ObjProductoDev.Numero        = int.Parse(this.dgv_Doc.CurrentRow.Cells[1].Value.ToString());
            ObjProductoDev.Fecha_Factura = DateTime.Parse(this.txt_fecha.Text);
            ObjProductoDev.Referencia    = this.dgv_Doc.CurrentRow.Cells[2].Value.ToString();
            ObjProductoDev.Descripcion   = this.dgv_Doc.CurrentRow.Cells[3].Value.ToString();
            ObjProductoDev.Talla         = this.dgv_Doc.CurrentRow.Cells[4].Value.ToString();
            ObjProductoDev.Color         = this.dgv_Doc.CurrentRow.Cells[5].Value.ToString();
            ObjProductoDev.UnidadesVenta = int.Parse(this.dgv_Doc.CurrentRow.Cells[6].Value.ToString());
            ObjProductoDev.Precio        = decimal.Parse(this.dgv_Doc.CurrentRow.Cells[10].Value.ToString());
            ObjProductoDev.Almacen       = this.dgv_Doc.CurrentRow.Cells[12].Value.ToString();
            ObjProductoDev.Retornable    = this.dgv_Doc.CurrentRow.Cells[11].Value.ToString();
            ObjProductoDev.CodBarra      = this.dgv_Doc.CurrentRow.Cells[13].Value.ToString();
            ObjProductoDev.CodColor      = this.dgv_Doc.CurrentRow.Cells[14].Value.ToString();
            ObjProductoDev.CodArticulo   = int.Parse(this.dgv_Doc.CurrentRow.Cells[15].Value.ToString());
            ObjProductoDev.NumLinea      = int.Parse(this.dgv_Doc.CurrentRow.Cells[16].Value.ToString());
            ObjProductoDev.Linea_Fact    = int.Parse(this.dgv_Doc.CurrentRow.Cells[16].Value.ToString());



            ObjProductoDev.Procesado = false;

            byte[] FotoItem = ObjProcDB.BuscarFotoArticulo(ObjDaConnexion, ObjProductoDev.CodArticulo);

            PBArticulos.Image = byteArrayToImage(FotoItem);

            if (FotoItem != null)
            {
                PBArticulos.Image = byteArrayToImage(FotoItem);
            }
            else
            {
                RutaImagen        = Settings.Default.PathImagCUST + "NOIMAGEN" + ".jpg";
                PBArticulos.Image = Image.FromFile(RutaImagen);
            }



            if (ObjProductoDev.Retornable == "T")
            {
                FormDevolucion v1 = new FormDevolucion(ref ObjProductoDev, ObjDaConnexion, oUserSistemasLog);
                v1.ShowDialog();
                this.Show();

                if (ObjProductoDev.RazonDevolucion != null && ObjProductoDev.UnidadesDevueltas != 0)
                {
                    if (ObjProductoDev.Procesado)
                    {
                        ObjListaNCR = ObjProcDB.ValidarDevolucion(ObjDaConnexion, ObjProductoDev.Serie, ObjProductoDev.Numero, ObjProductoDev.CodBarra, ObjProductoDev.UnidadesDevueltas, ObjProductoDev.Linea_Fact);
                        // TotalProducDev = (from NotasCredito in ObjListaNCR where NotasCredito.UnidadesDevueltas != 0 select sum(NotasCredito));

                        if (ObjListaNCR.Count > 0)
                        {
                            bool procesar = false;
                            //Debe ser una sola validacion
                            //foreach (var item in ObjListaNCR)
                            //{
                            TotalProducDev = (from NotasCredito in ObjListaNCR select NotasCredito.UnidadesDevueltas).Sum();
                            //procesar = ValidarDevolucion( ObjListaNCR[0], TotalProducDev + ObjProductoDev.UnidadesDevueltas);
                            procesar = ValidarDevolucion(ObjProductoDev, TotalProducDev + ObjProductoDev.UnidadesDevueltas);
                            if (procesar)
                            {
                                ObjListaProductosDev.Add(ObjProductoDev);
                                CargarGridProductosDev(ObjListaProductosDev);
                            }
                            //}
                        }
                        else
                        {
                            bool procesar = false;
                            TotalProducDev = (from ProductoDev in ObjListaProductosDev
                                              where ProductoDev.CodBarra.ToString() == ObjProductoDev.CodBarra.ToString() &
                                              ProductoDev.NumLinea == ObjProductoDev.NumLinea
                                              select ProductoDev.UnidadesDevueltas).Sum();

                            if (ObjProductoDev.UnidadesDevueltas + TotalProducDev > ObjProductoDev.UnidadesVenta)
                            {
                                MessageBox.Show("El Artículo " + ObjProductoDev.CodBarra + " de la Factura " + ObjProductoDev.Serie + " " + ObjProductoDev.Numero +
                                                " Ya esta incluida para Procesar como Devolución", "Información", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                return;
                            }

                            foreach (var someobject in ObjListaProductosDev)
                            {
                                if (someobject.CodBarra.ToString() == dgv_Doc.CurrentRow.Cells[13].Value.ToString())
                                {
                                    procesar = true;
                                    someobject.UnidadesDevueltas = ObjProductoDev.UnidadesDevueltas + TotalProducDev;
                                }
                                //ObjListaProductosDev.Add(ObjProductoDev);
                                //CargarGridProductosDev(ObjListaProductosDev);
                            }

                            if (procesar)
                            {
                                ObjListaProductosDev.Add(ObjProductoDev);
                                Dgv_ProductosDev.DataSource = null;
                                Dgv_ProductosDev.DataSource = ObjListaProductosDev;
                            }
                            else
                            {
                                ObjListaProductosDev.Add(ObjProductoDev);
                                CargarGridProductosDev(ObjListaProductosDev);
                            }
                        }
                    }
                }
            }

            else
            {
                MessageBox.Show("Producto no acepta Devolución", "Notificación", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }