コード例 #1
0
        private void btnMAS_Click(object sender, EventArgs e)
        {
            /* if (oMATERIAL.STOCK < Convert.ToInt32(txtCANTIDAD.Text))
             * {
             *   MessageBox.Show("La cantidad ingresada supera al stock, pongase en contacto con soporte");
             *   return;
             * }*/
            if (string.IsNullOrEmpty(txtCANTIDAD.Text))
            {
                MessageBox.Show("Debe ingresar una cantidad mayor a 0");
                return;
            }
            int cantidadd = Convert.ToInt32(txtCANTIDAD.Text);

            if (cantidadd <= 0)
            {
                MessageBox.Show("Debe ingresar una cantidad correcta");
                return;
            }
            if (string.IsNullOrEmpty(txtCANTIDAD.Text))
            {
                MessageBox.Show("Debe ingresar una cantidad mayor a 0");
                return;
            }
            if (string.IsNullOrEmpty(txtPUC.Text))
            {
                MessageBox.Show("Debe ingresar un PUC valido");
                return;
            }
            if (string.IsNullOrEmpty(txtDESCUENTO.Text))
            {
                MessageBox.Show("Debe ingresar un descuento valido");
                return;
            }
            if (Convert.ToInt32(txtDESCUENTO.Text) < 0 || (Convert.ToInt32(txtDESCUENTO.Text) > 100))
            {
                MessageBox.Show("El numero de descuento ingresado es incorrecto");
                return;
            }

            if (string.IsNullOrEmpty(txtCANTIDADD.Text))
            {
                MessageBox.Show("Debe ingresar un descuento valido");
                return;
            }

            Int32 cantidad;

            cantidad     = (Convert.ToInt32(txtCANTIDAD.Text));
            totalivadesc = 0;
            puc          = double.Parse(txtPUC.Text);
            cantidad     = Convert.ToInt16(txtCANTIDAD.Text);
            double total = (puc * cantidad);

            ///////iva

            double ivaParcial = (oMATERIAL.IVA * total) / 100;
            ///descuento
            ///


            double descuentoparcial = (Convert.ToDouble(txtDESCUENTO.Text) * total) / 100;

            if ((cantidad > oMATERIAL.STOCK))
            {
                MessageBox.Show("La cantidad ingresada supera el stock actual de este material");
                return;
            }


            int count = 0;



            //oORDEN = new MODELO.OrdenCompra();
            //oCANTMAT = new MODELO.CantidadMat();

            //oMATERIAL = (MODELO.Materiales)dgvMATERIALES.CurrentRow.DataBoundItem;

            //oCANTMAT.Material = oMATERIAL;
            //oCANTMAT.Cantidad_mat = Convert.ToInt32(txtCANTIDAD.Text);

            //cCantMat.agregarCantMat(oCANTMAT);



            for (int i = 0; i < listaCantMateriales.LongCount(); i++)
            {
                if (listaCantMateriales[i].Material.DESCRIPCION_CORTA == oMATERIAL.DESCRIPCION_CORTA)
                {
                    MessageBox.Show("El material ya existe");

                    return;
                }
                count++;
            }



            if (count == listaMateriales.LongCount())
            {
                listaMateriales.Add(oMATERIAL);
                ////listaCantMateriales.Add(oCANTMAT);
                listaImportes.Add(total);
                listaIva.Add(ivaParcial);
                listaDescuentos.Add(descuentoparcial);
            }

            for (int i = 0; i < listaImportes.LongCount(); i++)
            {
                totalfinal     += total;
                totaliva       += ivaParcial;
                totaldescuento += descuentoparcial;
            }

            /////total + iva con el desc

            double totalivadescparcial = ((total + ivaParcial) - descuentoparcial);

            if (count == listaPrecioTotal.LongCount())
            {
                listaPrecioTotal.Add(totalivadescparcial);
            }
            totalivadesc = 0;
            for (int i = 0; i < listaPrecioTotal.LongCount(); i++)
            {
                totalivadesc += totalivadescparcial;
            }
            MODELO.CantidadMat mat = new MODELO.CantidadMat();
            mat.Material            = oMATERIAL;
            mat.Cantidad_mat        = Convert.ToInt32(txtCANTIDAD.Text);
            mat.cantidad_base_venta = mat.Cantidad_mat;

            oMATERIAL.PUC = Convert.ToInt32(txtPUC.Text);
            //oMATERIAL.STOCK = oMATERIAL.STOCK - Convert.ToInt32(txtCANTIDAD.Text);
            //cMateriales.modificarMateriales(oMATERIAL);

            cCantMat.agregarCantMat(mat);
            listaCantMateriales.Add(mat);


            dgvOCM.DataSource    = null;
            dgvOCM.DataSource    = listaCantMateriales;
            txtCANTIDAD.Enabled  = false;
            txtPUC.Enabled       = false;
            txtDESCUENTO.Enabled = false;
            txtCANTIDAD.Text     = "";
            txtPUC.Text          = "";
            txtIVA.Text          = "";
            txtDESCUENTO.Text    = "";

            txtIMPORTE_TOTAL.Text = totalivadesc.ToString();
            txtDTOTOTAL.Text      = totaldescuento.ToString();
            txtIMPORTE.Text       = totalfinal.ToString();
            txtIVATOTAL.Text      = totaliva.ToString();
            //double total = myList.Sum(item => item.Amount);



            dgvOCM.Enabled = true;
            //txtIMPORTE.Text = Convert.ToInt32(txtCANTIDAD.Text * txtPUC.Text);
        }
コード例 #2
0
        public void button2_Click(object sender, EventArgs e) // boton +
        {
            if (txtCANTIDAD.Text == "" || Convert.ToInt32(txtCANTIDAD.Text) < 0)
            {
                MessageBox.Show("Debe ingresar una cantidad correcta");
                return;
            }
            try
            {
                Int32.Parse(txtPUC.Text);
            }
            catch
            {
                MessageBox.Show("El PUC es invalido");
                return;
            }
            if (txtPUC.Text == "" || Convert.ToInt32(txtPUC.Text) < 0)
            {
                MessageBox.Show("Debe ingresar un puc correcto");
                return;
            }
            if (txtDESCUENTO.Text == "" || Convert.ToInt32(txtDESCUENTO.Text) < 0 || Convert.ToInt32(txtDESCUENTO.Text) >= 100)
            {
                MessageBox.Show("Debe ingresar un descuento correcto");
                return;
            }

            Int32 cantidad;

            cantidad     = (Convert.ToInt32(txtCANTIDAD.Text));
            totalivadesc = 0;
            puc          = double.Parse(txtPUC.Text);
            cantidad     = Convert.ToInt16(txtCANTIDAD.Text);
            double total = (puc * cantidad);

            double ivaParcial = (oMATERIAL.IVA * total) / 100;

            ///descuento
            ///
            if (Convert.ToInt32(txtDESCUENTO.Text) < 0 || (Convert.ToInt32(txtDESCUENTO.Text) > 100))
            {
                MessageBox.Show("El numero de descuento ingresado es incorrecto");
                return;
            }
            if (DateTime.Now > dtpFECHARECEPCION.Value)
            {
                MessageBox.Show("La fecha de entrega no puede ser anterior a la fecha de hoy. Pongase en contacto con soporte");
                return;
            }

            double descuentoparcial = (Convert.ToDouble(txtDESCUENTO.Text) * total) / 100;

            /*if ((cantidad + oMATERIAL.STOCK) > oMATERIAL.MAXIMO)
             * {
             *  MessageBox.Show("La cantidad ingresada supera el MAXIMO de ese material, ponganse en contacto con el soporte");
             *  return;
             * }*/

            if (string.IsNullOrEmpty(txtCANTIDAD.Text))
            {
                MessageBox.Show("Debe ingresar una cantidad mayor a 0");
                return;
            }
            if (string.IsNullOrEmpty(txtPUC.Text))
            {
                MessageBox.Show("Debe ingresar un PUC valido");
                return;
            }
            if (string.IsNullOrEmpty(txtDESCUENTO.Text))
            {
                MessageBox.Show("Debe ingresar un descuento valido");
                return;
            }
            int count = 0;

            //oORDEN = new MODELO.OrdenCompra();
            //oCANTMAT = new MODELO.CantidadMat();

            //oMATERIAL = (MODELO.Materiales)dgvMATERIALES.CurrentRow.DataBoundItem;

            //oCANTMAT.Material = oMATERIAL;
            //oCANTMAT.Cantidad_mat = Convert.ToInt32(txtCANTIDAD.Text);

            //cCantMat.agregarCantMat(oCANTMAT);



            for (int i = 0; i < listaMateriales.LongCount(); i++)
            {
                if (listaMateriales[i] == oMATERIAL)
                {
                    MessageBox.Show("El material ya existe");

                    return;
                }
                count++;
            }



            if (count == listaMateriales.LongCount())
            {
                listaMateriales.Add(oMATERIAL);
                ////listaCantMateriales.Add(oCANTMAT);
                listaImportes.Add(total);
                listaIva.Add(ivaParcial);
                listaDescuentos.Add(descuentoparcial);
            }

            for (int i = 0; i < listaImportes.LongCount(); i++)
            {
                totalfinal     += total;
                totaliva       += ivaParcial;
                totaldescuento += descuentoparcial;
            }

            /////total + iva con el desc

            double totalivadescparcial = ((total + ivaParcial) - descuentoparcial);

            if (count == listaPrecioTotal.LongCount())
            {
                listaPrecioTotal.Add(totalivadescparcial);
            }
            totalivadesc = 0;
            for (int i = 0; i < listaPrecioTotal.LongCount(); i++)
            {
                totalivadesc += totalivadescparcial;
            }
            MODELO.CantidadMat mat = new MODELO.CantidadMat();
            mat.Material      = oMATERIAL;
            mat.Cantidad_mat  = Convert.ToInt32(txtCANTIDAD.Text);
            mat.cantidad_base = mat.Cantidad_mat;
            cCantMat.agregarCantMat(mat);
            listaCantMateriales.Add(mat);

            oMATERIAL.PUC = Convert.ToInt32(txtPUC.Text);
            cMateriales.modificarMateriales(oMATERIAL);

            dgvOCM.DataSource = null;
            dgvOCM.DataSource = listaCantMateriales;


            txtCANTIDAD.Enabled  = false;
            txtPUC.Enabled       = false;
            txtDESCUENTO.Enabled = false;
            txtCANTIDAD.Text     = "";
            txtPUC.Text          = "";
            txtDESCUENTO.Text    = "";

            txtIMPORTE_TOTAL.Text = totalivadesc.ToString();
            txtDTOTOTAL.Text      = totaldescuento.ToString();
            txtIMPORTE.Text       = totalfinal.ToString();
            txtIVATOTAL.Text      = totaliva.ToString();
            //double total = myList.Sum(item => item.Amount);



            //txtIMPORTE.Text = Convert.ToInt32(txtCANTIDAD.Text * txtPUC.Text);
        }