Exemplo n.º 1
0
        private void btnAGREGAR_Click(object sender, EventArgs e)
        {
            if (dgvOCM.Rows.Count == 0)
            {
                MessageBox.Show("La orden de Compra se encuentra vacia, por favor ingrese un material");
                return;
            }


            if (string.IsNullOrEmpty(txtNROFACTURA.Text))
            {
                MessageBox.Show("Debe ingresar un numero de orden");
                return;
            }
            if (string.IsNullOrEmpty(txtCLIENTE.Text))
            {
                MessageBox.Show("Debe seleccionar un cliente");
                return;
            }
            if (string.IsNullOrEmpty(dtpFECHA.Text))
            {
                MessageBox.Show("Debe ingresar una fecha");
                return;
            }



            oORDEN.nroFactura = txtNROFACTURA.Text;
            //oORDEN.Proveedor = oPROVEEDOR.razonSocial;
            oORDEN.Cliente = clientesovicj;

            //oORDEN.Proveedor =;
            //oORDEN.Proveedor = (MODELO.Proveedor)ToString();
            //oORDEN.Proveedor = txtPROVEEDOR.Text; /////////////////////////////////////////////////////////////////////////////////
            oORDEN.Fecha          = dtpFECHA.Value;
            oORDEN.IvaTotal       = Convert.ToDecimal(txtIVATOTAL.Text);
            oORDEN.Importe        = Convert.ToDecimal(totalivadesc);
            oORDEN.DescuentoTotal = Convert.ToDecimal(totaldescuento);
            //  oORDEN.CantidadesMat.Add(oCANTMAT);



            //foreach (MODELO.CantidadMat item in listaCantMateriales.ToList())
            //{


            //    MODELO.CantidadMat mat = new MODELO.CantidadMat();
            //    mat.Material = item.Material;
            //    mat.Cantidad_mat = item.Cantidad_mat;
            //    cCantMat.agregarCantMat(mat);
            //    listaCantMateriales.Add(mat);
            //    //oORDEN.CantidadesMat.Add(mat);



            //    // item.OrdenCompra.Add(oORDEN);
            //    // cCantMat.modificarCantMat(item);
            //    //oORDEN.CantidadesMat.Add(item);
            //    // cOrden.modificarOrden(oORDEN);


            //}
            oORDEN.visibily = true;



            MODELO.oCanmatVenta Occantmat = new MODELO.oCanmatVenta();
            foreach (MODELO.CantidadMat item in listaCantMateriales)
            {
                //int cantidadd = Convert.ToInt32(txtCANTIDAD.Text);
                oMATERIAL             = item.Material;
                Occantmat.cantidadmat = item;
                Occantmat.venta       = oORDEN;
                Occantmat.material    = item.Material.DESCRIPCION_CORTA;
                Occantmat.cantidadmat.cantidad_base_venta = item.cantidad_base_venta;

                oMATERIAL = (MODELO.Materiales)cMateriales.obtenerMaterialNombree(item.Material.DESCRIPCION_CORTA)[0];

                oMATERIAL.STOCK -= item.Cantidad_mat;
                cMateriales.modificarMateriales(oMATERIAL);

                cOccantmat.agregarOccantmatVenta(Occantmat);
            }

            //oMATERIAL.STOCK = oMATERIAL.STOCK - Convert.ToInt32(txtCANTIDAD.Text);



            this.DialogResult = DialogResult.OK;
            AGREGAR_AUDITORIA("Alta", oORDEN);
        }
Exemplo n.º 2
0
        private void btnAGREGAR_Click(object sender, EventArgs e)
        {
            if (listaMaterialesUpdated.Count == 0)
            {
                MessageBox.Show("Debe agregar por lo menos un material");
                return;
            }


            listanuevax2          = new List <MODELO.Materiales>();
            listanuevax3          = new List <Int32>();
            listanuevax2          = cOccantmat.obtenerNuevax2(oOrden);
            listanuevax3          = cOccantmat.obtenerCantidadxD(oOrden);
            oRemito.NroRemito     = txtNROREMITO.Text;
            oRemito.Proveedor     = oProvedorNew;
            oRemito.OrdenDeCompra = orderC;
            oRemito.Fecha         = DateTime.Now;
            oRemito.Localidad     = oOrden.Localidad;

            #region eval. prov

            //A = FECHA Y CANTIDAD OK, B = CANTIDAD OK Y FECHA MAL, C = CANTIDAD MAL O CANTIDAD Y FECHA MAL

            for (int i = 0; i < ocantmat.LongCount(); i++)
            {
                cantidadRequerida += ocantmat[i].cantidadmat.Cantidad_mat;
            }

            if (cantidadRequerida == cantidadIngresada)
            {
                if (oOrden.Fecha_Recepcion.Date >= dtpFECHARECEPCION.Value.Date)
                {
                    oProvedorNew.tipo = "A";
                }
                else if (oOrden.Fecha_Recepcion.Date < dtpFECHARECEPCION.Value.Date)
                {
                    oProvedorNew.tipo = "B";
                }
            }
            else if (cantidadRequerida > cantidadIngresada)
            {
                if (oOrden.Fecha_Recepcion.Date >= dtpFECHARECEPCION.Value.Date || oOrden.Fecha_Recepcion.Date <= dtpFECHARECEPCION.Value.Date)
                {
                    oProvedorNew.tipo = "C";
                }
            }

            #endregion

            foreach (var item in listaMaterialesUpdated)
            {
                oUpdated = item;

                for (int i = 0; i < ocantmat.LongCount(); i++)
                {
                    if (ocantmat[i].cantidadmat.Cantidad_mat == oUpdated.Cantidad_Ingresada)
                    {
                        oRemito.CalifCantidad = "A";
                        if (oOrden.Fecha_Recepcion.Date == dtpFECHARECEPCION.Value.Date)
                        {
                            oRemito.CalifTiempo = "A tiempo";
                        }
                    }
                    else if (ocantmat[i].cantidadmat.Cantidad_mat != oUpdated.Cantidad_Ingresada)
                    {
                        oRemito.CalifCantidad = "B";
                        if (oOrden.Fecha_Recepcion.Date == dtpFECHARECEPCION.Value.Date)
                        {
                            oRemito.CalifTiempo = "A tiempo";
                        }
                        else if (oOrden.Fecha_Recepcion.Date < dtpFECHARECEPCION.Value.Date)
                        {
                            oRemito.CalifTiempo = "Tarde";
                        }
                    }
                }
            }
            //oMaterial

            int count = 0;
            foreach (var item in listaMaterialesUpdated)
            {
                oUpdated = item;
                cRemitoUpdated.agregarRemitoUpdated(oUpdated);

                for (int i = 0; i < ocantmat.LongCount(); i++)
                {
                    if (ocantmat[i].material == oUpdated.material)
                    {
                        ocantmat[i].cantidadmat.Cantidad_mat -= oUpdated.Cantidad_Ingresada;
                        cCANTMAT.modificarCantMat(ocantmat[i].cantidadmat);
                        oMaterial = (MODELO.Materiales)cMateriales.obtenerMaterialNombree(ocantmat[i].material)[0];

                        oMaterial.STOCK += oUpdated.Cantidad_Ingresada;
                        cMateriales.modificarMateriales(oMaterial);
                    }
                }
            }
            for (int i = 0; i < ocantmat.LongCount(); i++)
            {
                if (ocantmat[i].cantidadmat.Cantidad_mat == 0)
                {
                    count++;
                }
            }
            if (count == ocantmat.LongCount())
            {
                oOrden.visibily = false;
            }


            cREMITO.agregarRemito(oRemito);

            AGREGAR_AUDITORIA("Alta", oRemito);
            this.DialogResult = DialogResult.OK;
        }