コード例 #1
0
ファイル: funciones.cs プロジェクト: devsantoshm/System-s
        public void borrar_producto(DataGridView grilla, Label total, TextBox codigo, Label totalticket, Label iva, Label stock)
        {
            try
            {
                valordescontar = double.Parse(grilla.Rows[grilla.CurrentRow.Index].Cells[4].Value.ToString());

                DialogResult resulta = MessageBox.Show("Desea eliminar el elemento?", "Atencion", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (resulta == DialogResult.Yes)
                {
                    var des_iva = new recursos();
                    if (grilla.Rows[grilla.CurrentRow.Index].Cells[1].Value.ToString() == "888")
                    {
                        goto ignorar;
                    }
                    recursos.cantidades[grilla.Rows[grilla.CurrentRow.Index].Cells[1].Value.ToString()] += int.Parse(grilla.Rows[grilla.CurrentRow.Index].Cells[2].Value.ToString());
                    stock.Text = "La cantidad en stock es: " + recursos.cantidades[grilla.Rows[grilla.CurrentRow.Index].Cells[1].Value.ToString()].ToString();
ignorar:
                    grilla.Rows.RemoveAt(grilla.CurrentRow.Index);
                    recursos.total_venta -= valordescontar;
                    recursos.iva_venta   -= des_iva.iva(valordescontar, 5);
                    productos.contador   -= 1;
                    if (recursos.total_venta <= 0.0)
                    {
                        recursos.total_venta = 0;
                        total.Text           = "$0";
                        totalticket.Text     = "$" + recursos.total_venta.ToString("###,###,###");

                        iva.Text = "$" + "0";
                    }
                    else
                    {
                        totalticket.Text = "$" + recursos.total_venta.ToString("###,###,###");
                        total.Text       = "$" + recursos.total_venta.ToString("###,###,###");
                        iva.Text         = "$" + recursos.iva_venta.ToString("###,###,###");
                    }
                    codigo.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #2
0
ファイル: funciones.cs プロジェクト: jccasasramos/System-s
        public void cargargrilla(Grilla grilla, TextBox codigo, Label lbltotal, Label lbltotalticket, Label lbliva, Label cantidad, Label stock)
        {
            conectar();
            string consulta;
            bool   existe   = false;
            int    posicion = 0;

            try
            {
                consulta = "select *from productos where codigo='" + codigo.Text + "'";
                this.cmd = new SQLiteCommand(consulta, this.cn);
                this.rd  = this.cmd.ExecuteReader();
                if (rd.Read())
                {
                    if (!recursos.cant_oficiales.ContainsKey(codigo.Text))
                    {
                        recursos.cant_oficiales.Add(codigo.Text, int.Parse(rd["stock"].ToString()));
                    }
                    if (recursos.cant_oficiales[codigo.Text] != int.Parse(rd["stock"].ToString()))
                    {
                        MessageBox.Show(string.Format("Se ha modificado el stock\n Cantidad Anterior: {0} \n Cantidad Actual: {1} \n Como Consecuencia se modificara el stock en cola(memoria)", recursos.cant_oficiales[codigo.Text].ToString(), rd["stock"].ToString()), "Atencion Usuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        recursos.cant_oficiales[codigo.Text] = int.Parse(rd["stock"].ToString());
                        modificar_stock_memoria(grilla, ref recursos.cantidades, int.Parse(rd["stock"].ToString()), codigo.Text);
                        MessageBox.Show(recursos.cantidades[codigo.Text].ToString());
                    }
                    if (!recursos.cantidades.ContainsKey(codigo.Text))
                    {
                        recursos.cantidades.Add(codigo.Text, int.Parse(rd["stock"].ToString()));
                    }
                    if ((recursos.cantidades[codigo.Text] - recursos.cantidadprod) <= int.Parse(rd["minimo"].ToString()))
                    {
                        MessageBox.Show("Stock Insuficiente");
                        return;
                    }
                    else
                    {
                        recursos.cantidades[codigo.Text] -= recursos.cantidadprod;
                    }
                    for (int i = 0; i < grilla.Rows.Count; i++)
                    {
                        if (grilla.Rows[i].Cells[1].Value.ToString() == codigo.Text)
                        {
                            existe   = true;
                            posicion = i;
                        }
                    }
                    if (existe)
                    {
                        //grilla.Rows.Add();
                        grilla[0, posicion].Value = rd["descripcion"].ToString();
                        grilla[1, posicion].Value = codigo.Text;
                        grilla[2, posicion].Value = (int.Parse(grilla.Rows[posicion].Cells[2].Value.ToString()) + recursos.cantidadprod).ToString();
                        grilla[3, posicion].Value = rd["pventa"].ToString();
                        this.total = double.Parse((double.Parse(rd["pventa"].ToString()) * recursos.cantidadprod).ToString());
                        grilla[4, posicion].Value = (double.Parse(grilla.Rows[posicion].Cells[4].Value.ToString()) + this.total).ToString();
                    }
                    else
                    {
                        grilla.Rows.Add();
                        grilla[0, contador].Value = rd["descripcion"].ToString();
                        grilla[1, contador].Value = codigo.Text;
                        grilla[2, contador].Value = recursos.cantidadprod.ToString();
                        grilla[3, contador].Value = rd["pventa"].ToString();
                        this.total = double.Parse((double.Parse(rd["pventa"].ToString()) * recursos.cantidadprod).ToString());
                        grilla[4, contador].Value = this.total.ToString();
                        contador++;
                    }

                    recursos.total_venta += total;
                    stock.Visible         = true;
                    stock.Text            = "La cantidad en stock es: " + recursos.cantidades[codigo.Text].ToString();
                    codigo.Text           = string.Empty;
                    //   var pedidos_form = new form_pedidos();
                    lbltotal.Text       = "$" + recursos.total_venta.ToString("###,###,###");
                    lbltotalticket.Text = "$" + recursos.total_venta.ToString("###,###,###");
                    var cal_iva = new recursos();
                    recursos.iva_venta   += cal_iva.iva(total, 5);
                    lbliva.Text           = "$" + recursos.iva_venta.ToString("###,###,###");
                    recursos.cantidadprod = 1;
                    if (cantidad.Visible)
                    {
                        cantidad.Visible = false;
                    }
                    codigo.Focus();
                }
                else
                {
                    MessageBox.Show("No Existe el Producto en la base de datos", "No Existe", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    codigo.Text = string.Empty;
                    codigo.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                rd.Close();
            }
        }