Пример #1
0
 /// <summary>
 /// Конструктор статического класса
 /// </summary>
 static Settings()
 {
     try
     {
         if (File.Exists(FILE_NAME))
         {
             using (StreamReader fp = new StreamReader(FILE_NAME, System.Text.Encoding.UTF8))
             {
                 cont = JsonConvert.DeserializeObject <Conteiner>(fp.ReadToEnd());
             }
         }
         else
         {
             cont = new Conteiner()
             {
                 DDNS = "s.mtudev.ru"
             };
             File.Create(FILE_NAME);
             update();
         }
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show("ScrTilla", "Нет доступа к \"" + FILE_NAME + "\"\n\n" + e.Message, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
     }
 }
Пример #2
0
        private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (textBox3.Text.Contains("№"))
                {
                    int cantainerId = Int32.Parse(textBox3.Text.Split('?')[1].Split('№')[0]);
                    ConteinerRepository conteinerRepository = new ConteinerRepository();
                    ProductRepository   productRepository   = new ProductRepository();

                    Conteiner currConteiner = conteinerRepository.GetDataSource().First(n => n.Id == cantainerId);
                    Product   currProduct   = productRepository.GetDataSource().First(n => n.Id == currConteiner.ProductId);
                    string    productName   = currProduct.Name;
                    double    productWidth  = currConteiner.Weight;
                    int       productCount  = 1;
                    double    price         = Double.Parse(textBox1.Text);
                    AddProductContainer(productName, productWidth, productCount, price);

                    textBox3.Text = "";
                }
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        public void Print(Conteiner item, string productName)
        {
            this.item        = item;
            this.productName = productName;

            printDocument1.Print();
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Cliente,NumeroConteiner,TipoConteiner,StatusConteiner,CategoriaConteiner")] Conteiner conteiner)
        {
            if (id != conteiner.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(conteiner);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ConteinerExists(conteiner.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(conteiner));
        }
Пример #5
0
 public void Remove(Conteiner newConteiner)
 {
     using (var context = new StorageDbContext())
     {
         var recept =
             context.IngredientsForProducts.Where(element =>
                                                  element.ProductId == newConteiner.ProductId);
         foreach (var oneIngredientOfRecept in recept)
         {
             foreach (var onePackage in context.Packages)
             {
                 if (oneIngredientOfRecept.IngredientId == onePackage.IngredientId)
                 {
                     var weight = oneIngredientOfRecept.Weight * newConteiner.Weight * newConteiner.Amount;
                     if (weight <= onePackage.Weight)
                     {
                         onePackage.Weight -= weight;
                     }
                     else
                     {
                         throw new ArgumentOutOfRangeException();
                     }
                 }
             }
         }
         context.SaveChanges();
     }
 }
Пример #6
0
        public void Can_Resolve_Types()
        {
            var ioc = new Conteiner();

            ioc.For <ILogger>().Use <SqlServerLogger>();

            var logger = ioc.Resolve <ILogger>();

            Assert.AreEqual(typeof(SqlServerLogger), logger.GetType());
        }
Пример #7
0
        public void Can_Resolve_Concrete_Type()
        {
            var ioc = new Conteiner();

            ioc.For <ILogger>().Use <SqlServerLogger>();
            ioc.For(typeof(IRepository <>)).Use(typeof(SqlRepository <>));

            var service = ioc.Resolve <InvoiceService>();

            Assert.IsNotNull(service);
        }
Пример #8
0
        public void Can_Resolve_Types_Without_Default_Ctor()
        {
            var ioc = new Conteiner();

            ioc.For <ILogger>().Use <SqlServerLogger>();
            ioc.For <IRepository <Employee> >().Use <SqlRepository <Employee> >();

            var repository = ioc.Resolve <IRepository <Employee> >();

            Assert.AreEqual(typeof(SqlRepository <Employee>), repository.GetType());
        }
        public async Task <IActionResult> Create([Bind("ID,Cliente,NumeroConteiner,TipoConteiner,StatusConteiner,CategoriaConteiner")] Conteiner conteiner)
        {
            if (ModelState.IsValid)
            {
                _context.Add(conteiner);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(conteiner));
        }
Пример #10
0
 /// <summary>
 /// Создаёт новый файл настроек
 /// </summary>
 private static void CreateNewSettingFile()
 {
     cont = Conteiner.Default;
     if (!Directory.Exists(DIRECT_NAME))
     {
         Directory.CreateDirectory(DIRECT_NAME);
     }
     if (File.Exists(FILE_NAME))
     {
         File.Delete(FILE_NAME);
     }
     update();
 }
Пример #11
0
    private bool IsAboveGoodContainer()
    {
        ContactFilter2D filter = new ContactFilter2D();

        filter.layerMask   = gameObject.layer;
        filter.useTriggers = true;
        List <Collider2D> results = new List <Collider2D>();

        _circleCollider2D.OverlapCollider(filter, results);

        foreach (Collider2D collider in results)
        {
            Conteiner container = collider.GetComponent <Conteiner>();
            if (container != null)
            {
                if (_objectColor.HasFlag(container.ObjectColor))
                {
                    Conteiner.OnColorMatch?.Invoke(container.ObjectColor);
                    if (tapParticles)
                    {
                        tapParticles.Play();
                    }
                    _unmatched = false;
                    return(true);
                }
                else
                {
                    _unmatched = true;
                }
            }
            SecondaryObjectiveSocket socket = collider.GetComponent <SecondaryObjectiveSocket>();
            if (socket != null)
            {
                if (_objectColor.HasFlag(socket.SocketColor) && !socket.IsFull)
                {
                    socket.InstallGem(this);
                    if (tapParticles)
                    {
                        tapParticles.Play();
                    }
                    _unmatched = false;
                    return(true);
                }
                else
                {
                    _unmatched = true;
                }
            }
        }
        return(false);
    }
Пример #12
0
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                ProductRepository repos = new ProductRepository();
                double weight = double.Parse(maskedTextBox1.Text);

                int amount = Decimal.ToInt32(numericUpDown1.Value);

                int productId = repos.GetDataSource().Where(n => n.Name == comboBox1.SelectedItem.ToString()).FirstOrDefault().Id;

                if (weight < 0)
                {
                    MessageBox.Show(@"Некоректна вага продукту.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (amount < 0)
                {
                    MessageBox.Show(@"Некоректна кількість продукту.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                Conteiner entryProductConteiner = new Conteiner(productId, weight, amount);

                bool isOwn = entryProductsContainerCollection.Where(n => n.ProductId == entryProductConteiner.ProductId && n.Weight == entryProductConteiner.Weight).FirstOrDefault() != null;

                if (isOwn)
                {
                    entryProductsContainerCollection.Where(n => n.ProductId == entryProductConteiner.ProductId).First().Amount += amount;
                }
                else
                {
                    entryProductsContainerCollection.Add(entryProductConteiner);
                }

                UpdateListBoxProduct();
            }
            catch (FormatException)
            {
                MessageBox.Show(@"Введено некоректні дані продукту.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #13
0
        static void Main(string[] args)
        {
            Conteiner conteiner = new Conteiner();
            Cooker    cooker    = new Cooker();
            HotAction hotAction = new HotAction();

            //Make multicooker as facade class on actions above!
            MultiCooker multiCooker = new MultiCooker(conteiner, hotAction, cooker);

            //Make a boiling water
            multiCooker.MakeBoilingWater();

            //Make a meat dish
            multiCooker.MakeDishWithMeat();

            Console.ReadLine();
        }
Пример #14
0
        private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (radioButton1.Checked && comboBox1.Text.Contains("№"))
                {
                    int cantainerId = Int32.Parse(comboBox1.Text.Split('?')[1].Split('№')[0]);
                    ConteinerRepository conteinerRepository = new ConteinerRepository();

                    Conteiner currConteiner = conteinerRepository.GetDataSource().First(n => n.Id == cantainerId);
                    conteinerRepository.Remove(currConteiner.Id, dateTimePicker1.Value, 1, 1);

                    //MessageBox.Show(@"Об'єкт успішно списано.", "Sucsess", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    updateInformation();

                    comboBox1.Text = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #15
0
        /// <summary>
        /// Принудительно вызвать конструктор класса
        /// </summary>
        public static void RefreshClass()
        {
            StreamReader fp = null;

            try
            {
                if (File.Exists(FILE_NAME))
                {
                    using (fp = new StreamReader(FILE_NAME, System.Text.Encoding.UTF8))
                    {
                        cont = JsonConvert.DeserializeObject <Conteiner>(fp.ReadToEnd());
                    }
                    // если что-то не нашлось в настройках, создаём это сами:
                    // При таком подходе вполне возможно, что будет ADDRESS указывать на одно место, а HTTP_ADDRESS на default
                    // Чтобы это исправить, пользователю надо будет поприменить настройки в форме.
                    Conteiner Def = Conteiner.Default;
                    cont.ADDRESS      = cont.ADDRESS == null ? Def.ADDRESS : cont.ADDRESS;
                    cont.HTTP_ADDRESS = cont.HTTP_ADDRESS == null ? Def.HTTP_ADDRESS : cont.HTTP_ADDRESS;
                    cont.PNGs         = cont.PNGs == null ? Def.PNGs : cont.PNGs;
                    cont.UPLOAD       = cont.UPLOAD == null ? Def.UPLOAD : cont.UPLOAD;
                }
                else
                {
                    CreateNewSettingFile();
                }
            }
            catch (JsonException)
            {
                fp?.Close();
                CreateNewSettingFile();
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Нет доступа к \"" + FILE_NAME + "\"\n\n" + e.Message, "ScrTilla", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }
        }
Пример #16
0
 /// <summary>
 /// Сбрасывает настройки по-умлочанию.
 /// </summary>
 public static void ToDefault()
 {
     cont = Conteiner.Default;
     update();
 }
Пример #17
0
 /// <summary>
 /// Конструктор статического класса
 /// </summary>
 static Settings()
 {
     cont = new Conteiner();
     RefreshClass();
 }