예제 #1
0
        public void Form_Load(object sender, EventArgs e)
        {
            try
            {
                using (var repo = new AccountRepo())
                {
                    incomeAccountComboBox.DataSource = repo.GetAll();
                    outlayAccountComboBox.DataSource = repo.GetAll();
                }
                using (var repo = new TypeRepo())
                {
                    incomeTypeComboBox.DataSource = repo.GetAll();
                    outlayTypeComboBox.DataSource = repo.GetAll();
                }
                using (var repo = new PersonRepo())
                {
                    incomePersonComboBox.DataSource = repo.GetAll();
                    outlayPersonComboBox.DataSource = repo.GetAll();
                }
                incomeDatePicker.Value = DateTime.Now;
                outlayDatePicker.Value = DateTime.Now;

                if (i != null)
                {
                    tabControl1.TabPages.Remove(tabPage2);
                    incomeAccountComboBox.SelectedIndex = incomeAccountComboBox.Items.Cast <Account>().ToList().FindIndex(x => (x.ID == i.Account_ID));
                    incomeDatePicker.Value             = new DateTime(int.Parse(i.Year.ToString()), int.Parse(i.Month.ToString()), int.Parse(i.Day.ToString()));
                    incomeTypeComboBox.SelectedIndex   = incomeTypeComboBox.Items.Cast <Type>().ToList().FindIndex(x => (x.ID == i.Type_ID));
                    incomePersonComboBox.SelectedIndex = incomePersonComboBox.Items.Cast <Person>().ToList().FindIndex(x => (x.ID == i.Person_ID));
                    incomeValueBox.Text   = i.Value.ToString();
                    incomeCommentBox.Text = i.Comment;
                }
                else if (o != null)
                {
                    tabControl1.TabPages.Remove(tabPage1);
                    outlayAccountComboBox.SelectedIndex = outlayAccountComboBox.Items.Cast <Account>().ToList().FindIndex(x => (x.ID == o.Account_ID));
                    outlayDatePicker.Value             = new DateTime(int.Parse(o.Year.ToString()), int.Parse(o.Month.ToString()), int.Parse(o.Day.ToString()));
                    outlayTypeComboBox.SelectedIndex   = outlayTypeComboBox.Items.Cast <Type>().ToList().FindIndex(x => (x.ID == o.Type_ID));
                    outlayPersonComboBox.SelectedIndex = outlayPersonComboBox.Items.Cast <Person>().ToList().FindIndex(x => (x.ID == o.Person_ID));
                    outlayValueBox.Text   = o.Value.ToString();
                    outlayCommentBox.Text = o.Comment;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void LoadType()
        {
            var list = _TypeRepo.GetAll();

            ddlType.DataSource = list;
            ddlType.DataBind();
        }
 public void UpdateGrid()
 {
     try
     {
         using (var repo = new TypeRepo())
         {
             accountDataGrid.DataSource = repo.GetAll();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #4
0
        private void LoadType()
        {
            try
            {
                var list = _TypeRepo.GetAll();

                HttpContext.Current.Session["listType"] = list;
                ASPxGridView1_Type.DataSource           = list;
                ASPxGridView1_Type.DataBind();
            }
            catch //(Exception)
            {
                //throw;
            }
        }
예제 #5
0
        public void ExportDatabase(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var path = folderBrowserDialog1.SelectedPath;

            using (var repo = new AccountRepo())
            {
                var xEle = new XElement("Accounts",
                                        repo.GetAll().Select(account => new XElement("Account",
                                                                                     new XAttribute("ID", account.ID),
                                                                                     new XElement("Name", account.Name),
                                                                                     new XElement("CurrentAmount", account.CurrentAmount)
                                                                                     )));
                xEle.Save($"{path}\\accounts.xml");
            }
            using (var repo = new TypeRepo())
            {
                var xEle = new XElement("Types",
                                        repo.GetAll().Select(type => new XElement("Type",
                                                                                  new XAttribute("ID", type.ID),
                                                                                  new XElement("Name", type.Name)
                                                                                  )));
                xEle.Save($"{path}\\types.xml");
            }
            using (var repo = new PersonRepo())
            {
                var xEle = new XElement("Persons",
                                        repo.GetAll().Select(account => new XElement("Person",
                                                                                     new XAttribute("ID", account.ID),
                                                                                     new XElement("Name", account.Name)
                                                                                     )));
                xEle.Save($"{path}\\persons.xml");
            }
            using (var repo = new IncomeRepo())
            {
                var xEle = new XElement("Incomes",
                                        repo.GetAll().Select(income => new XElement("Income",
                                                                                    new XAttribute("ID", income.ID),
                                                                                    new XElement("Account", income.Account),
                                                                                    new XElement("Day", income.Day),
                                                                                    new XElement("Month", income.Month),
                                                                                    new XElement("Year", income.Year),
                                                                                    new XElement("Person", income.Person),
                                                                                    new XElement("Type", income.Type),
                                                                                    new XElement("Account", income.Value),
                                                                                    new XElement("Comment", income.Comment)
                                                                                    )));
                xEle.Save($"{path}\\incomes.xml");
            }
            using (var repo = new OutlayRepo())
            {
                var xEle = new XElement("Outlays",
                                        repo.GetAll().Select(outlay => new XElement("Outlay",
                                                                                    new XAttribute("ID", outlay.ID),
                                                                                    new XElement("Account", outlay.Account),
                                                                                    new XElement("Day", outlay.Day),
                                                                                    new XElement("Month", outlay.Month),
                                                                                    new XElement("Year", outlay.Year),
                                                                                    new XElement("Person", outlay.Person),
                                                                                    new XElement("Type", outlay.Type),
                                                                                    new XElement("Account", outlay.Value),
                                                                                    new XElement("Comment", outlay.Comment)
                                                                                    )));
                xEle.Save($"{path}\\outlays.xml");
            }
        }
예제 #6
0
 private IEnumerable <OrganizationType> GetAllTypesInternal()
 {
     return(TypeRepo.GetAll());
 }
예제 #7
0
        public void UpdateForm()
        {
            string      month      = currMonthLabel.Text.Substring(0, (currMonthLabel.Text.Length - 5));
            string      year       = currMonthLabel.Text.Substring(currMonthLabel.Text.Length - 4);
            int         index      = Array.IndexOf(_monthArray, month);
            int         monthQuery = index + 1;
            int         yearQuery  = int.Parse(year);
            List <Type> typeList;

            try
            {
                using (var repo = new TypeRepo())
                {
                    typeList = repo.GetAll();
                }
                if (_typeOfData == 1)
                {
                    List <Income> incomeList;
                    using (var repo = new IncomeRepo())
                    {
                        incomeList = (repo.GetAll()).FindAll(x =>
                                                             (x.Month == monthQuery && x.Year == yearQuery));
                    }
                    var list = (from a in incomeList
                                from b in typeList
                                where (a.Type_ID == b.ID)
                                select
                                new
                    {
                        Name = b.Name,
                        Sum = (from m in incomeList where m.Type_ID == b.ID select m.Value).Sum()
                    })
                               .Distinct().ToList();
                    chart1.DataSource = list;
                    chart2.DataSource = list;
                }
                else
                {
                    List <Outlay> outlayList;
                    using (var repo = new OutlayRepo())
                    {
                        outlayList = (repo.GetAll()).FindAll(x =>
                                                             (x.Month == monthQuery && x.Year == yearQuery));
                    }
                    var list = (from a in outlayList
                                from b in typeList
                                where (a.Type_ID == b.ID)
                                select
                                new
                    {
                        Name = b.Name,
                        Sum = (from m in outlayList where m.Type_ID == b.ID select m.Value).Sum()
                    })
                               .Distinct().ToList();
                    chart1.DataSource = list;
                    chart2.DataSource = list;
                    chart1.Series["Series1"].Color = System.Drawing.Color.Red;
                    chart2.Series["Series1"].Color = System.Drawing.Color.Red;
                }

                chart1.Series["Series1"].XValueMember  = "Name";
                chart1.Series["Series1"].XValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Int32;
                chart1.Series["Series1"].YValueMembers = "Sum";
                chart1.Series["Series1"].YValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Int32;

                chart2.Series["Series1"].XValueMember  = "Name";
                chart2.Series["Series1"].XValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Int32;
                chart2.Series["Series1"].YValueMembers = "Sum";
                chart2.Series["Series1"].YValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Int32;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }