Пример #1
0
 private void Clear_Table(DataGridView dataGridView)
 {
     dataGridView.DataSource = null;
     dataGridView.Rows.Clear();
     medRepos = prov.GetFactory().GetMedicineRepository();
     cosRepos = prov.GetFactory().GetCosmeticRepository();
 }
Пример #2
0
        public CosmeticMenu()
        {
            FactoryProvider prov = new FactoryProvider();

            cosRepos = prov.GetFactory().GetCosmeticRepository();
            cart     = prov.GetFactory().GetCartRepository();
            //cart.
            //cart = new CartFileRepository();
            factory = new FlyweightFactory();
        }
Пример #3
0
        public MedicineMenu()
        {
            FactoryProvider prov = new FactoryProvider();

            medRepos = prov.GetFactory().GetMedicineRepository();

            cart = prov.GetFactory().GetCartRepository();
            //cart = new CartFileRepository();

            factory = new FlyweightFactory();
        }
Пример #4
0
        public AppFormAdmin()
        {
            prov     = new FactoryProvider();
            medRepos = prov.GetFactory().GetMedicineRepository();
            cosRepos = prov.GetFactory().GetCosmeticRepository();

            InitializeComponent();
            //
            Load_Med_Columns();
            Load_Cos_Columns();
        }
Пример #5
0
 public AppFormUser()
 {
     factory   = new FlyweightFactory();
     prov      = new FactoryProvider();
     medRepos  = prov.GetFactory().GetMedicineRepository();
     cosRepos  = prov.GetFactory().GetCosmeticRepository();
     cartRepos = prov.GetFactory().GetCartRepository();
     InitializeComponent();
     //
     Load_Med_Columns();
     Load_Cos_Columns();
 }
Пример #6
0
        static void Main(string[] args)
        {
            var factory = FactoryProvider.GetFactory(ConfigurationManager.AppSettings["OS"]);
            var app     = new Application(factory);

            app.Start();
        }
Пример #7
0
        public override void Save()
        {
            List <string[]> list = new List <string[]>();

            foreach (var it in entities)
            {
                string[] str = new string[2];
                str[0] = it.Id.ToString();
                str[1] = it.name;
                list.Add(str);
            }
            string[] metaData = { "2", "int", "string" };
            factory.GetDataBase().UpdateTableContent(list, prov.GetFactory().GetTableName("AuthorTable"), metaData);

            //BinaryFactory bin = new BinaryFactory();
            //bin.GetDataBase().UpdateTableContent(list, "AuthorTable.binarytable", metaData);
        }
Пример #8
0
        static void Main(string[] args)
        {
            IFactory f = FactoryProvider.GetFactory("fs");

            f.GetLogger().Log("Hello");

            IFactory f2 = FactoryProvider.GetFactory("db");

            f2.GetLogger().Log("Hallo");
        }
Пример #9
0
        public void Add(string Name, string Surname, DateTime DateofBirth, string typo)
        {
            Student student = new Student();

            student.Name        = Name;
            student.Surname     = Surname;
            student.DateofBirth = DateofBirth.ToString();
            StudentDao studenCreator = FactoryProvider.GetFactory(typo).Creator(typo);

            studenCreator.Add(student);
        }
Пример #10
0
        public void Update(string Name, string Surname, DateTime DateofBirth, string StudentId, string typo)
        {
            Student student = new Student();

            student.Name        = Name;
            student.Surname     = Surname;
            student.DateofBirth = DateofBirth.ToString();
            student.StudentId   = Int32.Parse(StudentId);
            StudentDao studenCreator = FactoryProvider.GetFactory(typo).Creator(typo);

            studenCreator.Update(student);
        }
Пример #11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var     TypeOfFile = CmbFiles.SelectedItem.ToString();
            var     id         = Students.Count + 1;
            Student student    = new Student(id, txtBoxName.Text, txtBoxSurname.Text, txtBoxAge.Text);

            students.Add(students.Count + 1, student);
            IAbstractFactory FileCreate = FactoryProvider.GetFactory(TypeOfFile);

            var Return = FileCreate.CreateFile(student);

            MessageBox.Show(student.ToString());
        }
Пример #12
0
        public void TestFactoryProviderGetFactory()
        {
            //arrange
            FileFactory expectedFacory = new FileFactory();
            string      expectedString = expectedFacory.GetType().Name;
            //act
            FactoryProvider prov          = new FactoryProvider();
            var             actualFactory = prov.GetFactory();
            var             actualString  = actualFactory.GetType().Name;

            //assert
            Assert.AreEqual(expectedString, actualString);
        }
Пример #13
0
        private void ChooseDatabase(string database)
        {
            IFactory factory = FactoryProvider.GetFactory(database);

            repositories = new List <IRepository>();
            repositories.Clear();
            collections.Clear();
            studentsRepo  = factory.GetRepository("Students");
            teachersRepo  = factory.GetRepository("Teachers");
            facultiesRepo = factory.GetRepository("Faculties");
            repositories.Add(studentsRepo);
            repositories.Add(teachersRepo);
            repositories.Add(facultiesRepo);

            StudentsCollections studentsCollections = new StudentsCollections(studentsRepo.GetAll());
            TeachersCollections teachersCollections = new TeachersCollections(teachersRepo.GetAll());
            FacultiesCollection facultiesCollection = new FacultiesCollection(facultiesRepo.GetAll());

            collections.Add(studentsCollections);
            collections.Add(teachersCollections);
            collections.Add(facultiesCollection);

            //MenuHelper.
        }
Пример #14
0
 protected override IDataRepositoryContext GetDataContext()
 {
     return(FactoryProvider.GetFactory <DapperFactory>().CurrentDataContext as IDataRepositoryContext);
 }
Пример #15
0
        public void Init()
        {
            IFactory    factory           = FactoryProvider.GetFactory("DB");
            IRepository usersRepo         = factory.GetRepository("users");
            IRepository documentsRepo     = factory.GetRepository("documents");
            IRepository issuanceformsRepo = factory.GetRepository("issuanceforms");
            int         choise            = 0;

            while (choise != 5)
            {
                Console.Write("\nSee information (1)\n" +
                              "Take the document (2)\n" +
                              "Take back the document (3)\n" +
                              "See debtors (4)\n" +
                              "Exit (5)\n");

                choise = Convert.ToInt32(Console.ReadLine());
                Console.Clear();

                if (choise == 1)
                {
                    Console.WriteLine("Choose repository (documents, users, issuanceforms)");
                    string repo = Console.ReadLine();

                    try
                    {
                        List <IModel> models = factory.GetRepository(repo).GetAll();
                        foreach (IModel model in models)
                        {
                            Console.WriteLine(model);
                        }
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Can't find repository \"{0}\"", repo);
                    }
                }
                else if (choise == 2)
                {
                    //todo
                    Console.WriteLine("Enter user's name: ");

                    //try
                    User user = (User)usersRepo.Get(new UserFilter {
                        user_name = Console.ReadLine()
                    })[0];

                    //try
                    List <IModel> documents = documentsRepo.Get(new DocumentFilter {
                        owner_id = user.user_id, existence = true
                    });

                    Console.WriteLine("Choose document:");

                    for (int i = 0; i < documents.Count; i++)
                    {
                        Console.WriteLine((i + 1).ToString() + ":\n" + documents[i]);
                    }

                    int documentNumber = Convert.ToInt32(Console.ReadLine()) - 1;

                    if
                    (
                        issuanceformsRepo.Add(new IssuanceForm
                    {
                        date_of_issue = DateTime.Now,
                        was_returned = false,
                        document_id = ((Document)documents[documentNumber]).document_id,
                        user_id = user.user_id
                    })
                    )
                    {
                        documentsRepo.Update(new DocumentFilter {
                            owner_id = user.user_id, document_id = ((Document)documents[documentNumber]).document_id
                        }, new DocumentFilter {
                            existence = false
                        });
                        Console.WriteLine("\nDone");
                    }
                    else
                    {
                        Console.WriteLine("\nError");
                    }
                }
                else if (choise == 3)
                {
                    //todo
                    Console.WriteLine("Enter user's name: ");

                    //try
                    User user = (User)usersRepo.Get(new UserFilter {
                        user_name = Console.ReadLine()
                    })[0];

                    List <IModel> issuanceForms = issuanceformsRepo.Get(new IssuanceFormFilter {
                        user_id = user.user_id
                    });

                    Console.WriteLine("Choose issuance form:");

                    for (int i = 0; i < issuanceForms.Count; i++)
                    {
                        Console.WriteLine((i + 1).ToString() + ":\n" + issuanceForms[i]);
                    }

                    int issuanceFormNumber = Convert.ToInt32(Console.ReadLine()) - 1;

                    if (
                        issuanceformsRepo.Update(new IssuanceFormFilter
                    {
                        user_id = user.user_id,
                        document_id = ((IssuanceForm)issuanceForms[issuanceFormNumber]).document_id
                    },
                                                 new IssuanceFormFilter {
                        was_returned = true
                    })

                        )
                    {
                        documentsRepo.Update(new DocumentFilter {
                            owner_id = user.user_id, document_id = ((IssuanceForm)issuanceForms[issuanceFormNumber]).document_id
                        }, new DocumentFilter {
                            existence = true
                        });
                        Console.WriteLine("\nDone");
                    }
                    else
                    {
                        Console.WriteLine("\nError");
                    }
                }
                else if (choise == 4)
                {
                    List <IModel> issuanceforms = issuanceformsRepo.Get(new IssuanceFormFilter {
                        was_returned = false
                    });
                    if (issuanceforms.Count > 0)
                    {
                        foreach (IModel model in issuanceforms)
                        {
                            Console.WriteLine(usersRepo.Get(new UserFilter {
                                user_id = ((IssuanceForm)model).user_id
                            }));
                        }
                    }
                    else
                    {
                        Console.WriteLine("No debtors");
                    }
                }
            }
        }
Пример #16
0
        public MedicineMenu()
        {
            FactoryProvider prov = new FactoryProvider();

            medRepos = prov.GetFactory().GetMedicineRepository();
        }
Пример #17
0
        public CosmeticMenu()
        {
            FactoryProvider prov = new FactoryProvider();

            cosRepos = prov.GetFactory().GetCosmeticRepository();
        }
Пример #18
0
 public AuthorRepository()
 {
     prov          = new FactoryProvider();
     factory       = prov.GetFactory();
     this.entities = GetTableFromeDataBase();
 }