Beispiel #1
0
 public void AcceptButton_Click(object sender, EventArgs e)
 {
     try
     {
         using (var repo = new TypeRepo())
         {
             if (t == null)
             {
                 repo.Add(new Type()
                 {
                     Name = typeNameBox.Text
                 });
             }
             else
             {
                 t.Name = Name = typeNameBox.Text;
                 repo.Save(t);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        public void DelButton_Click(object sender, EventArgs e)
        {
            var t = accountDataGrid.CurrentRow?.DataBoundItem as Type;

            if (t == null)
            {
                return;
            }
            if (MessageBox.Show("Видалити обране поле?", "Видалення", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) ==
                DialogResult.OK)
            {
                try
                {
                    using (var repo = new TypeRepo())
                    {
                        repo.Delete(t);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                UpdateGrid();
            }
        }
Beispiel #3
0
 public override void InitializeLoading(Log log)
 {
     if (_elementType != null)
     {
         _listTypeRepo = Serializer.GetOrCreateRepo(log, _elementType);
     }
 }
Beispiel #4
0
    public override void InitializeLoading(Log log)
    {
        if (_elementType != null)
        {
            _listTypeRepo = Serializer.GetOrCreateRepo(log, _elementType);
        }

        _propertyInfoCapacity = LoadableType.GetProperty("Capacity");
    }
        public void UpdateType(OrganizationType type)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            TypeRepo.Update(type);
            unit_of_work.Commit();

            _is_type_cache_valid = false;
        }
        public void DeleteType(long typeId)
        {
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            TypeRepo.Delete(typeId);
            unit_of_work.Commit();

            _is_type_cache_valid = false;
        }
Beispiel #7
0
        public PropertyRepo(PropertySchema propertySchema, TypeRepo typeRepo = null)
        {
            PropertySchema = propertySchema;
            TypeRepo       = typeRepo;

            if (typeRepo?.Serializer.PublicOnly == true && PropertySchema.IsPrivate)
            {
                PropertySchema.IsLoadable = false;
            }
        }
Beispiel #8
0
        public FieldRepo(FieldSchema fieldSchema, TypeRepo typeRepo = null)
        {
            FieldSchema = fieldSchema;
            TypeRepo    = typeRepo;

            if (typeRepo?.Serializer.PublicOnly == true && FieldSchema.IsPrivate)
            {
                FieldSchema.IsLoadable = false;
            }
        }
Beispiel #9
0
    public override void InitializeLoading(Log log)
    {
        // these base types might not be serialized
        if (_typeKey != null)
        {
            _list1TypeRepo = Serializer.GetOrCreateRepo(log, _typeKey);
        }

        if (_typeValue != null)
        {
            _list2TypeRepo = Serializer.GetOrCreateRepo(log, _typeValue);
        }
    }
 public void UpdateGrid()
 {
     try
     {
         using (var repo = new TypeRepo())
         {
             accountDataGrid.DataSource = repo.GetAll();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Beispiel #11
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseSwagger();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            using (var scope = app.ApplicationServices.CreateScope())
            {
                var repo  = scope.ServiceProvider.GetRequiredService <IAvatarRepository>();
                var orepo = scope.ServiceProvider.GetRequiredService <IOwnerRepository>();
                var trepo = scope.ServiceProvider.GetRequiredService <ITypeRepository>();

                /* repo.Create(new Avatar { Name = "Chili", AvatarType = "Magician", Color = "Pink" });
                 * repo.Create(new Avatar { Name = "Bunsy", AvatarType = "Healer", Color = "Black" });*/

                IAvatarRepository aRepo  = new AvatarRepo();
                IOwnerRepository  owRepo = new OwnerRepo();
                ITypeRepository   tyrepo = new TypeRepo();


                DBInit.InitData(); // Mock data
                IAvatarService aService  = new AvatarService(aRepo);
                IOwnerService  owService = new OwnerService(owRepo);
                ITypeService   tService  = new TypeService(tyrepo);



                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
                    // c.RoutePrefix = string.Empty;
                });

                app.UseHttpsRedirection();
                app.UseRouting();

                app.UseCors("CustomerAppAllowSpecificOrigins");


                app.UseAuthorization();

                app.UseEndpoints(endpoints =>
                {
                    endpoints.MapControllers();
                });
            }
        }
Beispiel #12
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);
            }
        }
        public long CreateType(string caption)
        {
            Debug.Assert(!string.IsNullOrEmpty(caption));

            OrganizationType type = new OrganizationType {
                Caption = caption
            };
            var unit_of_work = UnitOfWorkProvider.GetUnitOfWork();

            unit_of_work.BeginTransaction();
            TypeRepo.Create(type);
            unit_of_work.Commit();

            _is_type_cache_valid = false;

            return(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");
            }
        }
 private IEnumerable <OrganizationType> GetAllTypesInternal()
 {
     return(TypeRepo.GetAll());
 }
        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);
            }
        }