コード例 #1
0
        private void showGrid()
        {
            FinanceCategory    financeCategory    = new FinanceCategory();
            FinanceCategorySub financeCategorySub = new FinanceCategorySub();
            Finance            finance            = new Finance();

            if (cmbBuscarCategory.SelectedItem != null)
            {
                financeCategory = (FinanceCategory)cmbBuscarCategory.SelectedItem;
            }
            if (cmbBuscarCategorySub.SelectedItem != null)
            {
                financeCategorySub = (FinanceCategorySub)cmbBuscarCategorySub.SelectedItem;
            }

            financeCategory.Type       = this.Type;
            finance.FinanceCategorySub = financeCategorySub;
            finance.FinanceCategorySub.FinanceCategory = financeCategory;
            dgList.Rows.Clear();
            foreach (Finance x in FinanceDAO.ListAllBy(finance))
            {
                dgList.Rows.Add(x.Id, x.FinanceCategorySub.FinanceCategory.Name + ", " + x.FinanceCategorySub.Name,
                                Util.moneyFormat_ptBR(x.Value), x.Date, FinanceU.ArraySituation[x.Situation],
                                x.PaymentForm.Name, FinanceU.ArrayPriority[x.Priority]);
            }
        }
コード例 #2
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);
        }
コード例 #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
        public static FinanceCategory GetByID(FinanceCategory financeCategoryVO)
        {
            DBEntities db = SingletonObjectContext.Instance.Context;

            try
            {
                return(db.FinanceCategories.FirstOrDefault(x => x.Id.Equals(financeCategoryVO.Id) && x.Status > 0));
            }
            catch
            {
                return(null);
            }
        }
コード例 #6
0
        public static int CountByName(FinanceCategory financeCategoryVO)
        {
            DBEntities db = SingletonObjectContext.Instance.Context;

            try
            {
                return(db.FinanceCategories.Count(x => x.Id != financeCategoryVO.Id && x.Status > 0 && x.Type.Equals(financeCategoryVO.Type) && x.Name.Equals(financeCategoryVO.Name)));
            }
            catch
            {
                return(0);
            }
        }
コード例 #7
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";
        }
コード例 #8
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";
        }
コード例 #9
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";
        }
コード例 #10
0
        public static bool Update(FinanceCategory financeCategoryVO)
        {
            DBEntities db = SingletonObjectContext.Instance.Context;

            try
            {
                financeCategoryVO.DateUpdate      = DateTime.Now;
                db.Entry(financeCategoryVO).State = EntityState.Modified;
                db.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #11
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();
         }
     }
 }
コード例 #12
0
        public static bool Insert(FinanceCategory financeCategoryVO)
        {
            DBEntities db = SingletonObjectContext.Instance.Context;

            try
            {
                financeCategoryVO.Status     = SystemU.STATUS_ATIVO;
                financeCategoryVO.DatePost   = DateTime.Now;
                financeCategoryVO.DateUpdate = DateTime.Now;
                db.FinanceCategories.Add(financeCategoryVO);
                db.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #13
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.");
                }
            }
        }
コード例 #14
0
        private void showGrid()
        {
            FinanceCategory    financeCategory    = new FinanceCategory();
            FinanceCategorySub financeCategorySub = new FinanceCategorySub();

            if (cmbBuscarType.SelectedIndex != 0)
            {
                financeCategory.Type = cmbBuscarType.SelectedIndex;
            }
            if (cmbBuscarCategory.SelectedItem != null)
            {
                financeCategory = (FinanceCategory)cmbBuscarCategory.SelectedItem;
            }

            financeCategorySub.FinanceCategory = financeCategory;
            dgList.Rows.Clear();
            foreach (FinanceCategorySub x in FinanceCategorySubDAO.ListAllBy(financeCategorySub))
            {
                dgList.Rows.Add(x.Id, x.Name, x.FinanceCategory.Name);
            }
        }
コード例 #15
0
        public static IOrderedEnumerable <FinanceCategory> ListFinanceByType(FinanceCategory financeCategoryVO)
        {
            DBEntities db = SingletonObjectContext.Instance.Context;

            return(db.FinanceCategories.Include("collFinanceCategorySub").Include("collFinanceCategorySub.collFinance").Where(x => x.Status > 0 && x.Type.Equals(financeCategoryVO.Type)).ToList().OrderBy(x => x.Name));
        }