示例#1
0
        private bool validateForm(FinanceCategory financeCategory)
        {
            financeCategory.Type = cmbType.SelectedIndex;
            if (financeCategory.Type.Equals(0) || cmbType.Text.Trim().Equals(""))
            {
                lblErrorType.Text = "Campo obrigatório";
                cmbType.Focus();
                return(false);
            }
            lblErrorType.Text = "";

            financeCategory.Name = txtName.Text.Trim();
            if (financeCategory.Name.Equals(""))
            {
                lblErrorName.Text = "Campo obrigatório.";
                txtName.Focus();
                return(false);
            }
            if (FinanceCategoryDAO.CountByName(financeCategory) > 0)
            {
                lblErrorName.Text = "Já consta cadastrado.";
                return(false);
            }
            lblErrorName.Text = "";

            return(true);
        }
示例#2
0
 private void showGrid()
 {
     dgList.Rows.Clear();
     foreach (FinanceCategory x in FinanceCategoryDAO.ListAll())
     {
         dgList.Rows.Add(x.Id, x.Name, FinanceCategoryU.ArrayType[x.Type]);
     }
 }
示例#3
0
        private void showChart()
        {
            DateTime dateIn  = DateTime.Parse(dtDateIn.Text);
            DateTime dateEnd = DateTime.Parse(dtDateEnd.Text);
            bool     check   = false;
            double   gastos  = 0;
            int      i       = 1;

            for (int j = 0; j < chtCategorias.Series.Count; j++)
            {
                chtCategorias.Series.RemoveAt(j);
            }

            chtCategorias.Titles.Clear();
            chtCategorias.Titles.Add("Gastos no perído de " + dateIn.ToShortDateString() + " até " + dateEnd.ToShortDateString());

            FinanceCategory fc = new FinanceCategory();

            fc.Type = FinanceCategoryU.TYPE_GASTO;
            foreach (FinanceCategory x in FinanceCategoryDAO.ListFinanceByType(fc))
            {
                if (x.Status > 0)
                {
                    gastos = 0;
                    check  = false;
                    foreach (FinanceCategorySub y in x.collFinanceCategorySub)
                    {
                        if (y.Status > 0)
                        {
                            foreach (Finance z in y.collFinance)
                            {
                                if (z.Status > 0 &&
                                    DateTime.Compare(z.Date, dateIn) >= 0 &&
                                    DateTime.Compare(z.Date, dateEnd) <= 0)
                                {
                                    gastos += z.Value;
                                    check   = true;
                                }
                            }
                        }
                    }
                }

                if (check)
                {
                    if (chtCategorias.Series.IsUniqueName("s" + x.Id))
                    {
                        chtCategorias.Series.Add("s" + x.Id);
                    }
                    chtCategorias.Series["s" + x.Id].LegendText = x.Name;
                    chtCategorias.Series["s" + x.Id].Points.AddXY(i, gastos);
                    i++;
                }
            }

            chtCategorias.Update();
        }
示例#4
0
        private void dgList_DoubleClick(object sender, EventArgs e)
        {
            FinanceCategory financeCategoryVO = new FinanceCategory();

            financeCategoryVO.Id  = int.Parse(dgList.CurrentRow.Cells["clId"].Value.ToString());
            financeCategoryVO     = FinanceCategoryDAO.GetByID(financeCategoryVO);
            cmbType.SelectedIndex = financeCategoryVO.Type;
            txtName.Text          = financeCategoryVO.Name;
            txtId.Text            = financeCategoryVO.Id.ToString();

            btnExcluir.Enabled = true;
        }
示例#5
0
        private void cmbBuscarType_SelectedValueChanged(object sender, EventArgs e)
        {
            FinanceCategory financeCategory = new FinanceCategory();

            financeCategory.Type = cmbBuscarType.SelectedIndex;

            cmbBuscarCategory.Items.Clear();
            cmbBuscarCategory.Items.Add("Carregando ...");
            cmbBuscarCategory.Items.Clear();
            foreach (FinanceCategory x in FinanceCategoryDAO.ListByType(financeCategory))
            {
                cmbBuscarCategory.Items.Add(x);
            }

            cmbBuscarCategory.ValueMember   = "Id";
            cmbBuscarCategory.DisplayMember = "Name";
        }
示例#6
0
        private void ShowCmbCategory()
        {
            FinanceCategory financeCategory = new FinanceCategory();

            financeCategory.Type = cmbType.SelectedIndex;

            cmbCategory.Items.Clear();
            cmbCategory.Items.Add("Carregando ...");
            cmbCategory.Items.Clear();
            foreach (FinanceCategory x in FinanceCategoryDAO.ListByType(financeCategory))
            {
                cmbCategory.Items.Add(x);
            }

            cmbCategory.ValueMember   = "Id";
            cmbCategory.DisplayMember = "Name";
        }
示例#7
0
        private void cmbCategory_Start()
        {
            FinanceCategory fc = new FinanceCategory();

            cmbCategory.Items.Add(fc);
            fc.Type = this.Type;
            foreach (FinanceCategory x in FinanceCategoryDAO.ListByType(fc))
            {
                cmbCategory.Items.Add(x);
                cmbBuscarCategory.Items.Add(x);
            }

            cmbCategory.ValueMember         = "Id";
            cmbCategory.DisplayMember       = "Name";
            cmbBuscarCategory.ValueMember   = "Id";
            cmbBuscarCategory.DisplayMember = "Name";
        }
示例#8
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Deseja mesmo este registro?", "Categoria", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         FinanceCategory financeCategoryVO = new FinanceCategory();
         financeCategoryVO.Id = int.Parse(txtId.Text);
         financeCategoryVO    = FinanceCategoryDAO.GetByID(financeCategoryVO);
         if (!FinanceCategoryDAO.UpdateDisable(financeCategoryVO))
         {
             MessageBox.Show("Erro: Ocorreu um erro inesperado excluir.");
         }
         else
         {
             MessageBox.Show("Excluído com sucesso.");
             this.ClearFields();
             this.showGrid();
         }
     }
 }
示例#9
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            FinanceCategorySub financeCategorySub = new FinanceCategorySub();
            int Id;

            if (int.TryParse(txtId.Text, out Id))
            {
                financeCategorySub.Id = Id;
                financeCategorySub    = FinanceCategorySubDAO.GetByID(financeCategorySub);
            }
            FinanceCategory financeCategory = new FinanceCategory();

            financeCategory = (FinanceCategory)cmbCategory.SelectedItem;
            financeCategory = FinanceCategoryDAO.GetByID(financeCategory);
            financeCategorySub.FinanceCategory = financeCategory;
            if (this.validateForm(financeCategorySub))
            {
                if (financeCategorySub.Id > 0)
                {
                    if (FinanceCategorySubDAO.Update(financeCategorySub))
                    {
                        MessageBox.Show("Alterado com sucesso.");
                        this.ClearFields();
                        this.showGrid();
                        return;
                    }
                    MessageBox.Show("Erro: Ocorreu um erro inesperado alterar.");
                }
                else
                {
                    if (FinanceCategorySubDAO.Insert(financeCategorySub))
                    {
                        MessageBox.Show("Cadastrado com sucesso.");
                        this.ClearFields();
                        this.showGrid();
                        return;
                    }
                    MessageBox.Show("Erro: Ocorreu um erro inesperado cadastrar.");
                }
            }
        }