Exemplo n.º 1
0
        public Frm_Gerar_Parcelas(Parcelas_PagarCollection parcela_todos_temp, int PCA_CARNE_TEMP, int ORIGEM_TEMP, float CAP_TOTAL_TEMP, float PCA_ACRESCIMO_TEMP, float PCA_DESCONTO_TEMP, DateTime PCA_VENC_TEMP, string COM_NF)
        {
            InitializeComponent();

            this.Text = Titulo_Tela("Gerar Parcelas");

            parcela_todos = new Parcelas_PagarCollection();
            PCA_CARNE     = PCA_CARNE_TEMP;
            ORIGEM        = ORIGEM_TEMP;
            CAP_TOTAL     = CAP_TOTAL_TEMP;
            PCA_ACRESCIMO = PCA_ACRESCIMO_TEMP;
            PCA_DESCONTO  = PCA_DESCONTO_TEMP;
            PCA_VENC      = PCA_VENC_TEMP;
            tb_nf.Text    = COM_NF;

            Limpar();

            foreach (Parcelas_Pagar parcela in parcela_todos_temp)
            {
                parcela_todos.Add(parcela);
            }
            if (CAP_TOTAL > 0)
            {
                tb_valor.Enabled  = false;
                tb_desc.Enabled   = false;
                tb_acresc.Enabled = false;
            }
            else
            {
                tb_valor.Enabled  = true;
                tb_desc.Enabled   = true;
                tb_acresc.Enabled = true;
            }
            tb_nf.Select();
        }
Exemplo n.º 2
0
        public Frm_Gerar_Parcelas(Parcelas_PagarCollection parcela_todos_temp, int PCA_CARNE_TEMP, int ORIGEM_TEMP, float CAP_TOTAL_TEMP, DateTime PCA_VENC_TEMP)
        {
            InitializeComponent();

            this.Text = Titulo_Tela("Gerar Parcelas");

            parcela_todos = new Parcelas_PagarCollection();
            PCA_CARNE     = PCA_CARNE_TEMP;
            ORIGEM        = ORIGEM_TEMP;
            CAP_TOTAL     = CAP_TOTAL_TEMP;
            PCA_VENC      = PCA_VENC_TEMP;

            Limpar();

            foreach (Parcelas_Pagar parcela in parcela_todos_temp)
            {
                parcela_todos.Add(parcela);
            }
            if (CAP_TOTAL > 0)
            {
                tb_valor.Enabled = false;
                cb_tipo.Select();
            }
            else
            {
                tb_valor.Enabled = true;
                tb_valor.Select();
            }
        }
Exemplo n.º 3
0
        public void Carregar_Grid(Parcelas_PagarCollection parcela_todos_temp)
        {
            parcela_todos = new Parcelas_PagarCollection();

            foreach (Parcelas_Pagar parcela in parcela_todos_temp)
            {
                parcela_todos.Add(parcela);
            }

            dgv_parcelas.DataSource = parcela_todos;

            foreach (DataGridViewRow row in dgv_parcelas.Rows)
            {
                if (parcela_todos[row.Index].PCA_VALOR_PAGO > 0)
                {
                    row.ReadOnly = true;
                }
                else
                {
                    row.ReadOnly = false;
                }
            }

            Calcular_Totais();
            Esconder_Colunas();
        }
Exemplo n.º 4
0
        private void dgv_parcelas_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Delete && int.Parse(lbl_linha.Text) >= 0)
            {
                if (parcela_todos[int.Parse(lbl_linha.Text)].PCA_VALOR_PAGO > 0)
                {
                    MessageBox.Show("Impossível excluir parcela já paga! É necessário estorná-la antes.", "3Pratos", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (parcela_todos[int.Parse(lbl_linha.Text)].PCA_ITEM_NOVA_PARC > 0)
                {
                    MessageBox.Show("Impossível excluir parcela parcial! É necessário excluir a parcela " + parcela_todos[int.Parse(lbl_linha.Text)].PCA_ITEM_NOVA_PARC.ToString() + " antes.", "3Pratos", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (MessageBox.Show("Deseja realmente excluir esta parcela?", "3Pratos", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    Parcelas_PagarCollection parcela_todos_temp      = new Parcelas_PagarCollection();
                    Cheques_PagarCollection  cheque_pagar_todos_temp = new Cheques_PagarCollection();
                    int PCA_ITEM = 1;

                    foreach (Cheques_Pagar cheque_pagar in cheque_pagar_todos)
                    {
                        cheque_pagar_todos_temp.Add(cheque_pagar);
                    }
                    cheque_pagar_todos.Clear();

                    foreach (Parcelas_Pagar parcela in parcela_todos)
                    {
                        if (parcela.PCA_ITEM != (int.Parse(lbl_linha.Text) + 1))
                        {
                            parcela.PCA_ITEM = PCA_ITEM++;
                            if (parcela.PCA_ITEM_NOVA_PARC == (int.Parse(lbl_linha.Text) + 1))
                            {
                                parcela.PCA_ITEM_NOVA_PARC = 0;
                            }
                            parcela_todos_temp.Add(parcela);

                            if (parcela.PCA_TIPO == 3)
                            {
                                foreach (Cheques_Pagar cheque_pagar in cheque_pagar_todos_temp)
                                {
                                    if (parcela.PCA_ITEM == cheque_pagar.CHP_ITEM)
                                    {
                                        cheque_pagar_todos.Add(cheque_pagar);
                                    }
                                }
                            }
                        }
                    }
                    Carregar_Grid(parcela_todos_temp);
                }
            }
        }
Exemplo n.º 5
0
        public void Carregar_Grid(Parcelas_PagarCollection parcela_todos_temp)
        {
            parcela_todos = new Parcelas_PagarCollection();
            float total_geral = 0;
            float total_pago  = 0;

            foreach (Parcelas_Pagar parcela in parcela_todos_temp)
            {
                if (parcela.PCA_VALOR_PAGO > 0)
                {
                    total_geral += parcela.PCA_VALOR_PAGO;
                    total_pago  += parcela.PCA_VALOR_PAGO;
                }
                else
                {
                    total_geral += parcela.PCA_VALOR;
                }
                parcela_todos.Add(parcela);
            }

            dgv_parcelas.DataSource = parcela_todos;

            foreach (DataGridViewRow row in dgv_parcelas.Rows)
            {
                if (parcela_todos[row.Index].PCA_VALOR_PAGO > 0)
                {
                    row.ReadOnly = true;
                }
                else
                {
                    row.ReadOnly = false;
                }
            }

            tb_total_geral.Text = total_geral.ToString("0.00");
            tb_total_pago.Text  = total_pago.ToString("0.00");

            Esconder_Colunas();
        }
Exemplo n.º 6
0
        private void btn_gerar_Click(object sender, EventArgs e)
        {
            if (tb_valor.Text == "")
            {
                tb_valor.Text = "0,00";
            }
            if (tb_parcelas.Text == "")
            {
                tb_parcelas.Text = "1";
            }
            if (tb_qtde.Text == "")
            {
                tb_qtde.Text = "1";
            }
            if (float.Parse(tb_valor.Text) == 0)
            {
                MessageBox.Show("Valor precisa ser maior que zero!", "Joincar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tb_valor.Focus();
            }
            else
            {
                float          valor_total   = float.Parse(tb_valor.Text);
                float          valor_gerado  = 0;
                float          acresc_total  = float.Parse(tb_acresc.Text);
                float          acresc_gerado = 0;
                float          desc_total    = float.Parse(tb_desc.Text);
                float          desc_gerado   = 0;
                DateTime       vencimento    = DateTime.Parse(tb_venc_1parc.Text);
                Parcelas_Pagar parcela;

                for (int i = 1; i <= int.Parse(tb_parcelas.Text); i++)
                {
                    parcela                    = new Parcelas_Pagar();
                    parcela.PCA_CARNE          = 0;
                    parcela.PCA_ITEM           = parcela_todos.Count + 1;
                    parcela.PCA_ITEM_NOVA_PARC = 0;
                    parcela.PCA_DATA_PAGTO     = DateTime.Parse("01/01/1800");
                    if (tb_nf.Text.Length > 0)
                    {
                        parcela.PCA_NUM_DOC = tb_nf.Text + "-" + parcela.PCA_ITEM.ToString();
                    }
                    else
                    {
                        parcela.PCA_NUM_DOC = "";
                    }
                    parcela.PCA_OBS  = tb_obs.Text;
                    parcela.PCA_TIPO = cb_tipo.SelectedIndex;

                    if (i == int.Parse(tb_parcelas.Text))
                    {
                        parcela.PCA_VALOR     = valor_total - valor_gerado;
                        parcela.PCA_DESCONTO  = desc_total - desc_gerado;
                        parcela.PCA_ACRESCIMO = acresc_total - acresc_gerado;
                    }
                    else
                    {
                        parcela.PCA_VALOR     = valor_total / int.Parse(tb_parcelas.Text);
                        parcela.PCA_DESCONTO  = desc_total / int.Parse(tb_parcelas.Text);
                        parcela.PCA_ACRESCIMO = acresc_total / int.Parse(tb_parcelas.Text);
                    }
                    valor_gerado  += parcela.PCA_VALOR;
                    desc_gerado   += parcela.PCA_DESCONTO;
                    acresc_gerado += parcela.PCA_ACRESCIMO;

                    parcela.PCA_VALOR_PAGO = 0;
                    parcela.PCA_VENC       = vencimento;
                    if (cb_intervalo.SelectedIndex == 0)
                    {
                        vencimento = vencimento.AddMonths(int.Parse(tb_qtde.Text));
                    }
                    else
                    {
                        vencimento = vencimento.AddDays(int.Parse(tb_qtde.Text));
                    }
                    parcela_todos.Add(parcela);
                }
                //Se for compra, concretiza-la
                if (ORIGEM == 1)
                {
                    ORIGEM = 2;
                }

                this.Close();
            }
        }