Пример #1
0
        private void btnAdicionarLan_Click(object sender, EventArgs e)
        {
            using (var lancar = new Lancar())
            {
                saldoAnterior = Convert.ToDecimal(labelSaldoAtual.Text);
                lancar.ShowDialog();


                if (lancar.comboBoxTipo.SelectedItem == null)
                {
                }
                else if (lancar.comboBoxTipo.SelectedItem.ToString() == "Retirada")
                {
                    HoraAbertura = DateTime.Now;
                    dataGridView1.Rows.Insert(0, (HoraAbertura.ToShortDateString() + "/" + HoraAbertura.ToShortTimeString()), lancar.textBoxObs.Text, "", lancar.textBoxValor.Text);
                    if (lancar.textBoxValor.Text != "")
                    {
                        labelSaldoAtual.Text = Convert.ToString((Convert.ToDecimal(labelSaldoAtual.Text) - Convert.ToDecimal(lancar.textBoxValor.Text)));
                    }
                }
                else if (lancar.comboBoxTipo.SelectedItem.ToString() == "Adicionando")
                {
                    HoraAbertura = DateTime.Now;
                    dataGridView1.Rows.Insert(0, (HoraAbertura.ToShortDateString() + "/" + HoraAbertura.ToShortTimeString()), lancar.textBoxObs.Text, lancar.textBoxValor.Text, "");
                    if (lancar.textBoxValor.Text != "")
                    {
                        labelSaldoAtual.Text = Convert.ToString(Convert.ToDecimal(labelSaldoAtual.Text) + Convert.ToDecimal(lancar.textBoxValor.Text));
                    }
                }
            }
        }
Пример #2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.RowCount; i++)
            {
                if (Convert.ToBoolean(dataGridView1.Rows[i].Cells["Selecionar"].Value) == true)
                {
                    using (var lancar = new Lancar())
                    {
                        lancar.ShowDialog();

                        if (lancar.comboBoxTipo.SelectedItem == null)
                        {
                        }
                        else if (lancar.comboBoxTipo.SelectedItem.ToString() == "Retirada")
                        {
                            HoraAbertura = DateTime.Now;
                            dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
                            dataGridView1.Rows.Insert(i, (HoraAbertura.ToShortDateString() + "/" + HoraAbertura.ToShortTimeString()), lancar.textBoxObs.Text, "", lancar.textBoxValor.Text);

                            if (lancar.textBoxValor.Text != "")
                            {
                                labelSaldoAtual.Text = Convert.ToString(saldoAnterior - Convert.ToDecimal(lancar.textBoxValor.Text));
                            }
                        }
                        else if (lancar.comboBoxTipo.SelectedItem.ToString() == "Adicionando")
                        {
                            HoraAbertura = DateTime.Now;
                            dataGridView1.Rows.Remove(dataGridView1.CurrentRow);
                            dataGridView1.Rows.Insert(i, (HoraAbertura.ToShortDateString() + "/" + HoraAbertura.ToShortTimeString()), lancar.textBoxObs.Text, lancar.textBoxValor.Text, "");
                            if (lancar.textBoxValor.Text != "")
                            {
                                labelSaldoAtual.Text = Convert.ToString(saldoAnterior + Convert.ToDecimal(lancar.textBoxValor.Text));
                            }
                        }
                    }
                }
            }
        }