Exemplo n.º 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            mensaje.MostrarMensaje(this.paquete);
            Nuevo_proveedor frmNewProv = new Nuevo_proveedor();

            frmNewProv.FormClosing += new FormClosingEventHandler(frmNewProv_Closing);
            frmNewProv.ShowDialog();
            Cantidad_textbox.Focus();
        }
Exemplo n.º 2
0
        private void agregar_button_Click_1(object sender, EventArgs e)
        {
            int   cantidad = 0;
            float precio   = 0;

            if (Codigo_textbox.Text.Equals(null) || Cantidad_textbox.Text.Equals(null) || precio_textbox.Text.Equals(null) || comboBox1.Text.Equals(null))
            {
                new Mensajes().DebeLlenarTodosLosCampos();
                Codigo_textbox.Focus();
                Codigo_textbox.SelectionStart  = 0;
                Codigo_textbox.SelectionLength = Codigo_textbox.Text.Length;
            }
            else if (new DAOProductos().GetProducts(new Validaciones().LimpiarString(Codigo_textbox.Text)) == null)
            {
                MessageBox.Show("El producto no existe, debe registrarlo.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Codigo_textbox.Focus();
                Codigo_textbox.SelectionStart  = 0;
                Codigo_textbox.SelectionLength = Codigo_textbox.Text.Length;
            }
            else if (!int.TryParse(Cantidad_textbox.Text, out cantidad))
            {
                MessageBox.Show("Debe ingresar un número entero en el campo cantidad.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Cantidad_textbox.Focus();
                Cantidad_textbox.SelectionStart  = 0;
                Cantidad_textbox.SelectionLength = Cantidad_textbox.Text.Length;
            }
            else if (!float.TryParse(precio_textbox.Text, out precio))
            {
                MessageBox.Show("Debe ingresar un número en el campo precio.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                precio_textbox.Focus();
                precio_textbox.SelectionStart  = 0;
                precio_textbox.SelectionLength = precio_textbox.Text.Length;
            }
            else
            {
                float resultado = float.Parse(Cantidad_textbox.Text) * float.Parse(precio_textbox.Text);
                costo_total_textbox.Text = Convert.ToString(resultado);
                PantallaCompras temp = new PantallaCompras();
                temp.Codigo    = Codigo_textbox.Text;
                temp.Producto  = descripcion_textbox.Text;
                temp.proveedor = comboBox1.Text;
                temp.cantidad  = int.Parse(Cantidad_textbox.Text);
                temp.precio    = float.Parse(costo_total_textbox.Text);
                temp.proveedor = comboBox1.Text;
                AgregarPantalla(temp);

                /*pantallita.Add(temp);
                 * dataGridView1.Columns.Clear();
                 * actualizaDGV();
                 * remarcarCodigo();*/
            }
        }
Exemplo n.º 3
0
        private void precio_textbox_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (!char.IsDigit(e.KeyChar) &&
                e.KeyChar != '.' &&
                !char.IsControl(e.KeyChar))
            {
                e.Handled = true;
            }

            bool IsDec  = false;
            int  nroDec = 0;

            for (int i = 0; i < precio_textbox.Text.Length; i++)
            {
                if (precio_textbox.Text[i] == '.')
                {
                    IsDec = true;
                }

                if (IsDec && e.KeyChar == '.' && !char.IsControl(e.KeyChar))
                {
                    e.Handled = true;
                }

                if (IsDec && nroDec++ >= 2 && !char.IsControl(e.KeyChar))
                {
                    e.Handled = true;
                }
            }

            /* if (e.KeyChar >= 48 && e.KeyChar <= 57)
             *   e.Handled = false;
             * else if (e.KeyChar == 46)
             *   e.Handled = (IsDec) ? true : false;
             * else
             *   e.Handled = true;*/
            if (e.KeyChar == (char)Keys.Enter)
            {
                int   cantidad = 0;
                float precio   = 0;
                if (Codigo_textbox.Text.Equals(null) || Cantidad_textbox.Text.Equals(null) || precio_textbox.Text.Equals(null) || comboBox1.Text.Equals(null))
                {
                    new Mensajes().DebeLlenarTodosLosCampos(); Codigo_textbox.Focus();
                    Codigo_textbox.SelectionStart  = 0;
                    Codigo_textbox.SelectionLength = Codigo_textbox.Text.Length;
                }
                else if (new DAOProductos().GetProducts(new Validaciones().LimpiarString(Codigo_textbox.Text)) == null)
                {
                    MessageBox.Show("El producto no existe, debe registrarlo.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Codigo_textbox.Focus();
                    Codigo_textbox.SelectionStart  = 0;
                    Codigo_textbox.SelectionLength = Codigo_textbox.Text.Length;
                }
                else if (!int.TryParse(Cantidad_textbox.Text, out cantidad))
                {
                    MessageBox.Show("Debe ingresar un número entero en el campo cantidad.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Cantidad_textbox.Focus();
                    Cantidad_textbox.SelectionStart  = 0;
                    Cantidad_textbox.SelectionLength = Cantidad_textbox.Text.Length;
                }
                else if (!float.TryParse(precio_textbox.Text, out precio))
                {
                    MessageBox.Show("Debe ingresar un número en el campo precio.", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    precio_textbox.Focus();
                    precio_textbox.SelectionStart  = 0;
                    precio_textbox.SelectionLength = precio_textbox.Text.Length;
                }
                else
                {
                    float resultado = float.Parse(Cantidad_textbox.Text) * float.Parse(precio_textbox.Text);
                    costo_total_textbox.Text = (float.Parse(Cantidad_textbox.Text) * float.Parse(precio_textbox.Text)).ToString();
                    PantallaCompras temp = new PantallaCompras();
                    temp.Codigo    = Codigo_textbox.Text;
                    temp.Producto  = descripcion_textbox.Text;
                    temp.proveedor = comboBox1.Text;
                    temp.cantidad  = int.Parse(Cantidad_textbox.Text);
                    temp.precio    = float.Parse(costo_total_textbox.Text);
                    temp.proveedor = comboBox1.Text;
                    AgregarPantalla(temp);

                    /* pantallita.Add(temp);
                     * dataGridView1.Columns.Clear();
                     * dataGridView1.DataSource = pantallita.ToArray();
                     * actualizaDGV();
                     * remarcarCodigo();*/
                }
            }
        }
Exemplo n.º 4
0
 private void frmNewProv_Closing(object sender, EventArgs e)
 {
     actualizaCombo();
     this.comboBox1.SelectedIndex = this.comboBox1.Items.Count - 1;
     Cantidad_textbox.Focus();
 }