/// <summary>
 /// حذف يك گروه حساب
 /// </summary>
 /// <param name="groupModel"></param>
 /// <returns></returns>
 public Models.ActionResultModelBinding RemoveGroup(Models.Group groupModel, bool confirmDeleteSubdivision)
 {
     try
     {
         using (var repo = new Repository.Repository(this, "usp_deleteAccountGroup"))
         {
             repo.cmd.Parameters.AddWithValue("@id", groupModel.Id);
             repo.cmd.Parameters.AddWithValue("@confirmDeleteSubdivision", confirmDeleteSubdivision);
             repo.ExecuteNonQuery();
             return(new Models.ActionResultModelBinding
             {
                 Message = repo.rMsg,
                 Status = repo.rCode == 1 ? Models.ActionResult.Success : Models.ActionResult.Failed
             });
         }
     }
     catch (Exception c)
     {
         return(new Models.ActionResultModelBinding
         {
             Message = c.Message,
             Status = Models.ActionResult.Failed
         });
     }
 }
Example #2
0
        static void Main(string[] args)
        {
            IntStatement st1 = new CompStatement(new AssignStatement("a", new ArithExpresion(1, new ConstExpresion(2), new
                                                                                             ArithExpresion(3, new ConstExpresion(3), new ConstExpresion(5)))),
                                                 new CompStatement(new AssignStatement("b", new ArithExpresion(1, new VarExpresion("a"), new
                                                                                                               ConstExpresion(1))), new PrintStatement(new VarExpresion("b"))));

            IntStatement st2 = new CompStatement(new CompStatement(new openRFile("var_f", "test.in"), new CompStatement(new readFile("var_f", "var_c"),
                                                                                                                        new PrintStatement(new VarExpresion("var_c")))),
                                                 new CompStatement(new IfStatement(new VarExpresion("var_c"),
                                                                                   new CompStatement(new readFile("var_f", "var_c"),
                                                                                                     new PrintStatement(new VarExpresion("var_c"))),
                                                                                   new PrintStatement(new ConstExpresion(0))), new CompStatement(new closeRFile("var_f"), new closeRFile("var_f"))));


            IntStatement st3 = new CompStatement(new CompStatement(new openRFile("var_f", "test.in"), new CompStatement(new readFile("var_f", "var_c"),
                                                                                                                        new PrintStatement(new VarExpresion("var_c")))),
                                                 new closeRFile("var_f"));


            System.Console.WriteLine("Log file path:");
            String        filen_name = System.Console.ReadLine();
            IntRepository rep        = new Repository.Repository(filen_name);

            Controller.Controller cont = new Controller.Controller(rep);

            cont.addPrgState(createProgState(st1));
            cont.addPrgState(createProgState(st2));
            cont.addPrgState(createProgState(st3));
            TextMenu menu = new TextMenu();

            menu.addCommand(new ExitCommand("0", "Exit!"));
            menu.addCommand(new AllStepsCommand("1", "Run all steps an example!", cont));
            menu.show();
        }
 /// <summary>
 /// دريافت ليست گروه هاي حساب
 /// </summary>
 /// <param name="_pageNo">
 /// شماره صفحه
 /// </param>
 /// <param name="_seedNumber">
 /// تعداد ركوردهاي مدنظر براي مشاهده در خروجي
 /// </param>
 /// <returns></returns>
 public Models.SelectResultModelBinding <Models.Group> GetGroupAccounts(short _pageNo = 0, short _seedNumber = 10, string search = null)
 {
     try
     {
         using (var repo = new Repository.Repository(this, "usp_getAccountGroupList", true))
         {
             pageNo     = _pageNo;
             seedNumber = _seedNumber;
             repo.cmd.Parameters.AddWithValue("@search", search);
             repo.ExecuteAdapter();
             var info = repo.ds.Tables[0].AsEnumerable();
             return(new Models.SelectResultModelBinding <Models.Group>
             {
                 Body = info.Select(i => new Models.Group
                 {
                     Id = Convert.ToInt32(i.Field <object>("id")),
                     Code = Convert.ToString(i.Field <object>("code")),
                     Title = Convert.ToString(i.Field <object>("title")),
                     IsDefault = Convert.ToBoolean(i.Field <object>("is_default")),
                     NatureId = Convert.ToInt16(i.Field <object>("fk_nature_id")),
                     NatureTitle = Convert.ToString(i.Field <object>("natureTitle"))
                 }).ToList(),
                 TotalCount = repo.totalCount
             });
         }
     }
     catch (Exception c)
     {
         System.Windows.MessageBox.Show(c.Message);
         return(null);
     }
 }
 /// <summary>
 /// ويرايش گروه حساب
 /// </summary>
 /// <param name="groupModel"></param>
 /// <returns></returns>
 public Models.ActionResultModelBinding UpdateGroup(Models.Group groupModel)
 {
     try
     {
         using (var repo = new Repository.Repository(this, "usp_updateAccountingGroup"))
         {
             repo.cmd.Parameters.AddWithValue("@id", groupModel.Id);
             repo.cmd.Parameters.AddWithValue("@code", groupModel.Code);
             repo.cmd.Parameters.AddWithValue("@title", groupModel.Title);
             repo.cmd.Parameters.AddWithValue("@natureId", groupModel.NatureId);
             repo.cmd.Parameters.AddWithValue("@isDefault", groupModel.IsDefault);
             repo.ExecuteNonQuery();
             return(new Models.ActionResultModelBinding
             {
                 Message = repo.rMsg,
                 Status = repo.rCode == 1 ? Models.ActionResult.Success : Models.ActionResult.Failed
             });
         }
     }
     catch (Exception c)
     {
         return(new Models.ActionResultModelBinding
         {
             Message = c.Message,
             Status = Models.ActionResult.Failed
         });
     }
 }
 private void RehberYukle()
 {
     repo = repo == null ? new Repository<Kisi>(this.RehberKisileriYukle()):repo;
     listBox1.DataSource = null;
     listBox1.DisplayMember = "KisiAdi";
     listBox1.DataSource = repo.TumunuGetir();
 }
Example #6
0
        public void AssignTableUser()
        {
            int i = 0;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                var user    = service.GetUserWithTable("gcorrea");
                if (user == null)
                {
                    Assert.Fail("User not exist");
                }
                else
                {
                    if (user.Tablets == null)
                    {
                        user.Tablets = new List <Table>();
                    }
                    user.Tablets.Clear();
                    user.Tablets.AddRange(service.GetTables(new List <int>()
                    {
                        1, 2, 3
                    }));
                    i = service.UpdateUser(user);
                }
                Assert.IsTrue(i > 0);
            }
        }
Example #7
0
 public void GetWaiter()
 {
     using (var db = new ShoppingContext())
     {
         var service  = new Repository.Repository(db);
         var products = service.GetProducts();
         Assert.IsTrue(products != null);
     }
 }
Example #8
0
        public void AddTables()
        {
            using (var db = new ShoppingContext())
            {
                var  service = new Repository.Repository(db);
                bool i       = service.TableRegister(20);

                Assert.IsTrue(i);
            }
        }
Example #9
0
        public void CloseTable()
        {
            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                int i       = service.CloseTable(1);

                Assert.IsTrue(i > 0);
            }
        }
Example #10
0
 public void AddLetter()
 {
     using (var db = new ShoppingContext())
     {
         LetterMenu c = new LetterMenu();
         c.Name = "Principal";
         var service = new Repository.Repository(db);
         var query   = service.AddLetterMenu(c);
         Assert.IsTrue(query > 0);
     }
 }
Example #11
0
        public void GetLetterComplete()
        {
            LetterMenu letter;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                letter = service.GetLetterMenuComplete("Principal");
            }
            Assert.IsTrue(letter.Categorys[0].Products.Count > 0);
        }
Example #12
0
        public void DisplayOrders()
        {
            IRepository<Order> repo = new Repository<Order>(new RepositoryTestDataContext());

            var allOrders = repo.GetAll();

            foreach (var item in allOrders.Take(10))
                {
                    Console.WriteLine("OrderId: {0} OrderDate: {1}", item.OrderID, item.OrderDate);
                }

                Console.WriteLine();
                Console.WriteLine();

                var filteredOrders = repo.Find(o => o.OrderDate <= new DateTime(1996, 7, 4));

                foreach (var item in filteredOrders.Take(10))
                {
                    Console.WriteLine("OrderId: {0} OrderDate: {1}", item.OrderID, item.OrderDate);
                }

                Console.WriteLine();
                Console.WriteLine("Insert new order");

                Order newOrder = new Order
                              {
                                   OrderDate = DateTime.Now,
                                   CustomerID = "ALFKI",
                                   EmployeeID = null,
                                   Freight = null,
                                   RequiredDate = DateTime.Now.AddDays(10),
                                   ShipAddress = "Obere Str. 57",
                                   ShipCity = "Berlin",
                                   ShipCountry = "Germany",
                                   ShipName = "Alfreds Futterkiste",
                                   ShipPostalCode = "12209",
                                   ShipVia = 1
                              };

                repo.Insert(newOrder);

            Order updateOrder;

            IRepository<Order> repo2 = new Repository<Order>(new RepositoryTestDataContext());

            updateOrder = repo2.GetById(11078);

            IRepository<Order> repo3 = new Repository<Order>(new RepositoryTestDataContext());

            updateOrder.EmployeeID = 1;
            repo3.Update(updateOrder);
        }
Example #13
0
        public void AddCategory()
        {
            using (var db = new ShoppingContext())
            {
                Category c = new Category();
                c.Description = "Todas las pastas";
                c.Name        = "Pastas";
                var service = new Repository.Repository(db);
                var query   = service.AddCategority(c, 1);

                Assert.IsTrue(query > 0);
            }
        }
Example #14
0
        public void AddWaiter()
        {
            using (var db = new ShoppingContext())
            {
                var product = new Waiter
                {
                    UserName = "******",
                    Password = "******"
                };
                var  service = new Repository.Repository(db);
                bool i       = service.AddUser(product);

                Assert.IsTrue(i);
            }
        }
Example #15
0
        public void InitAppFunctions()
        {
            var apps = Container.Resolve<IApps>();
            var funcs = Container.Resolve<IFunctions>();

            //var dbContext = new DatabaseContext();

            

            var adapter = Container.Resolve<IObjectContext>();

            var appRepo = new Repository<ApplicationTable>(adapter);

            var applicationTables = appRepo.FindNoTracking(s => true).ToList(); //TODO User Role
            

            if (!applicationTables.Any()) return;


            Apps = new KZBindingList<IApp>();

            foreach (var applicationTable in applicationTables)
            {
                if (!apps.ListApps.ContainsKey(applicationTable.Code)) continue;
                var app = apps.ListApps[applicationTable.Code].Clone() as IApp;

                if (app == null) continue;
                app.Id = applicationTable.Id;

                app.Functions = new KZBindingList<IFunction>();

                //TODO User Role

                foreach (var applicationFunctionTable in applicationTable.ApplicationFunctionTables)
                {
                    if (!funcs.ListFuncs.ContainsKey(applicationFunctionTable.FunctionTable.Code)) continue;

                    var func = funcs.ListFuncs[applicationFunctionTable.FunctionTable.Code].Clone() as IFunction;

                    if (func == null) continue;
                    func.Id = applicationFunctionTable.FunctionId;

                    app.Functions.Add(func);
                }

                Apps.Add(app);
            }
        }
Example #16
0
        public void Given()
        {
            var dbSet = new FakeDbSet <MyEntity>();

            MyEntity[] myEntities = { new MyEntity {
                                          Id = 1
                                      }, new MyEntity{
                                          Id = 2
                                      } };
            myEntities.ToList().ForEach(me => dbSet.Add(me));

            dbContext = A.Fake <IDbConctext>();
            A.CallTo(() => dbContext.Set <MyEntity>()).Returns(dbSet);

            sut = new Repository.Repository(dbContext);
        }
Example #17
0
        public void ListTableforUser()
        {
            int i = 0;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                var user    = service.GetUserWithTable("gcorrea");
                if (user == null)
                {
                    Assert.Fail("User not exist");
                }

                Assert.IsTrue(user.Tablets.Count > 0);
            }
        }
Example #18
0
        public void RemuveLetter()
        {
            LetterMenu letter;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                letter = service.GetLetterMenu("Principal");
            }
            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                int i       = service.RemoveLetter(letter);

                Assert.IsTrue(i > 0);
            }
        }
Example #19
0
        public void RemuveCategory()
        {
            Category category;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                category = service.GetCategory(1, "Carnes");
            }
            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                int i       = service.RemoveCategority(category);

                Assert.IsTrue(i > 0);
            }
        }
Example #20
0
        public void UpdateProduct()
        {
            Product product;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                product = service.GetProduct(1);
            }
            using (var db = new ShoppingContext())
            {
                product.Name = "Ravioles";
                var service = new Repository.Repository(db);
                int i       = service.UpdateProduct(product);

                Assert.IsTrue(i > 0);
            }
        }
Example #21
0
        public void AddNewOrder()
        {
            using (var db = new ShoppingContext())
            {
                var   service = new Repository.Repository(db);
                Order or      = new Order();
                or.Items = new List <ItemOrder>();
                ItemOrder item     = new ItemOrder();
                var       products = service.GetProducts();
                item.Prduct = products.ToList()[0];
                item.Count  = 2;
                or.Items.Add(item);
                or.Date = DateTime.Now;
                int i = service.AddOrder(1, or);

                Assert.IsTrue(i > 0);
            }
        }
Example #22
0
        public void AddProduct()
        {
            using (var db = new ShoppingContext())
            {
                var product = new Product
                {
                    Name        = "Ravioles",
                    Code        = "123456",
                    Description = "Ravioles",
                    Price       = 200
                };
                var service = new Repository.Repository(db);
                product.CategorityId = service.GetCategory(1, "Pastas").Id;
                int i = service.AddProduct(product);

                Assert.IsTrue(i > 0);
            }
        }
Example #23
0
        public void UpdateWaiter()
        {
            Waiter product;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                product = service.GetUser("psilva");
            }
            using (var db = new ShoppingContext())
            {
                product.Password = "******";
                var service = new Repository.Repository(db);
                int i       = service.UpdateUser(product);

                Assert.IsTrue(i > 0);
            }
        }
Example #24
0
        public void UpdateLetter()
        {
            LetterMenu letter;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                letter = service.GetLetterMenu("Principal");
            }
            using (var db = new ShoppingContext())
            {
                letter.Name = "Vinos";
                var service = new Repository.Repository(db);
                int i       = service.UpdateLetter(letter);

                Assert.IsTrue(i > 0);
            }
        }
Example #25
0
        public void UpdateCategory()
        {
            Category category;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                category = service.GetCategory(1, "Pastas");
            }
            using (var db = new ShoppingContext())
            {
                category.Name = "Carnes";
                var service = new Repository.Repository(db);
                int i       = service.UpdateCategority(category);

                Assert.IsTrue(i > 0);
            }
        }
        static void Main(string[] args)
        {
            SessionConfig config = new SessionConfig();
            ISession session = config.OpenSession();

            using (ITransaction transaction = session.BeginTransaction())
            {
                List<Doctor> doctorList = new List<Doctor>
                {
                    new Doctor {FirstName = "Michael", LastName="Jhonson"},
                    new Doctor {FirstName = "Anna", LastName="Nicolson"},
                    new Doctor {FirstName = "Jhon", LastName="Travolta"},
                };

                List<Pacient> pacientList = new List<Pacient>
                {
                    new Pacient { FirstName = "John", LastName="Smith"},
                    new Pacient { FirstName = "Ivan", LastName="Ivanov"},
                    new Pacient { FirstName = "Igor", LastName="Nikolaev"},
                };

                Record record = new Record { Doctor = doctorList.Last(), Pacient = pacientList.First(), Time = DateTime.Now };

                IRepository<Doctor> doctors = new Repository<Doctor>(session);
                doctors.Save(doctorList);

                IRepository<Pacient> pacients = new Repository<Pacient>(session);
                pacients.Save(pacientList);

                IRepository<Record> records = new Repository<Record>(session);
                records.Save(record);

                transaction.Commit();
            }

            ((List<Doctor>)(new Repository<Doctor>(session)).ReadAll()).ForEach(x => Console.WriteLine(x.LastName));
            Console.ReadLine();

            IRepository<Pacient> pacients1 = new Repository<Pacient>(session);
            ((List<Pacient>)(new Repository<Pacient>(session)).ReadAll()).ForEach(x => Console.WriteLine(x.LastName));

            Console.ReadLine();
        }
Example #27
0
        public void RemuveProduct()
        {
            Product product;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                product = service.GetProduct(1);
            }
            if (product != null)
            {
                using (var db = new ShoppingContext())
                {
                    var service = new Repository.Repository(db);
                    int i       = service.RemuveProduct(product);

                    Assert.IsTrue(i > 0);
                }
            }
            else
            {
                Assert.Fail("Product id: " + 1 + " not exist");
            }
        }
Example #28
0
        public void RemuveWaiter()
        {
            Waiter product;

            using (var db = new ShoppingContext())
            {
                var service = new Repository.Repository(db);
                product = service.GetUser("psilva");
            }
            if (product != null)
            {
                using (var db = new ShoppingContext())
                {
                    var service = new Repository.Repository(db);
                    int i       = service.RemoveUser(product);

                    Assert.IsTrue(i > 0);
                }
            }
            else
            {
                Assert.Fail("Product id: " + 1 + " not exist");
            }
        }
 public SearchMoviesScreen(Core.UIItems.WindowItems.Window window, Repository.ScreenRepository screenRepository)
     : base(window, screenRepository)
 {
 }
Example #30
0
        static void work1(object t)
        {
            Console.WriteLine("Start thread:{0}", Thread.CurrentThread.ManagedThreadId);
            //UnitOfWork.Begin("DBServer");
            //IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();
            //IProductRepository prodRep = new ProductRepository("DBServer");
            //Console.WriteLine("ProductID : {0} ", prodRep.First(x => x.Model == "PCBE15YA837Y"  && string.IsNullOrEmpty(x.CUSTSN)).ProductID);
            //Product p = prodRep.First(x => string.IsNullOrEmpty(x.CUSTSN));
            //p.CUSTSN = "test";
            //UnitOfWork uow = new UnitOfWork();
            //using (uow )
            //{
                IRepository<Product> prodRep = new Repository<Product>("HPIMES");
                IRepository<ProductStatus> prodStatusRep = new Repository<ProductStatus>("HPIMES");
                var E = (from p in prodRep.Query()
                         join s in prodStatusRep.Query() on p.ProductID equals s.ProductID
                         where p.ProductID == "A35500006 "
                         select new { prod = p }).ToList();

                Console.WriteLine("HPIMES productID: {0} ", E[0].prod.ProductID);

               // Product p = prodRep.Table
                var K = (from p in prodRep.Query()
                        //join s in prodStatusRep.Query() on p.ProductID equals s.ProductID
                        where p.ProductID == "A35500006 "
                        select p).ToList();
                
                

             
                Console.WriteLine("HPIMES productID: {0} ", K[0].ProductID);
                IRepository<ProductStatus> tsbprodStatusRep = new Repository<ProductStatus>("TSBIMES");
                var D = (from s in tsbprodStatusRep.Query()
                         where s.ProductID == "BE9000007"
                         select s).ToList();

                Console.WriteLine(" TSBIMES productID: {0} ", D[0].ProductID);

                K[0].CUSTSN = Thread.CurrentThread.ManagedThreadId.ToString();
                D[0].Station = Thread.CurrentThread.ManagedThreadId.ToString();

                UnitOfWork.ThreadCommit();
                //Product p1 = new Product
                //{
                //    ProductID ="A355000067",
                //    CUSTSN = "test1111",
                //    Model = "PCBE15YA837Y",
                //    PCBID = "",
                //    Udt = DateTime.Now.AddDays(-1)
                //};
                ////prodRep.Delete(p);
                //prodRep.Update(p1);


                ////foreach (Product item in prodRep.GetProductByModel("PCBE15YA837Y"))
                ////{
                ////    if (string.IsNullOrEmpty(item.CUSTSN))
                ////    {
                ////        item.CUSTSN = "";
                ////    }
                ////    Thread.Sleep(20);
                ////    Console.WriteLine("thread:{0} ProductID:{1} CustomSN:{2}", Thread.CurrentThread.ManagedThreadId,  item.ProductID, item.CUSTSN);
                ////}

                ////prodRep.Save();
                //uow.Commit();
            //}
            Console.WriteLine("End thread:{0}", Thread.CurrentThread.ManagedThreadId);
        }
Example #31
0
        static void work2()
        {
            Console.WriteLine("Start thread:{0}", Thread.CurrentThread.ManagedThreadId);
            //UnitOfWork uow = new UnitOfWork();
            //UnitOfWork.Begin("DBServer");
            //IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository>();
            //IProductRepository prodRep = new ProductRepository("DBServer");
            //Console.WriteLine("ProductID : {0} ", prodRep.Single(x => string.IsNullOrEmpty( x.CUSTSN)).ProductID);
            //using (UnitOfWork uow = new UnitOfWork())
            //{
             IRepository<Product> prodRep = new Repository<Product>("HPIMES");
                //foreach (Product item in prodRep.Find(x => x.Model == "PCBE15YA837Y"))
                //{
                //    if (string.IsNullOrEmpty(item.CUSTSN))
                //    {
                //        item.CUSTSN = "";
                //    }
                //    Thread.Sleep(20);
                //    Console.WriteLine("thread:{0} ProductID:{1} CustomSN:{2}", Thread.CurrentThread.ManagedThreadId, item.ProductID, item.CUSTSN);
                //}

                Product p1 = new Product
                {
                    ProductID = "A35500006 ",
                    CUSTSN = "test1111",
                    Model = "PCBE15YA837Y",
                    PCBID = "",
                    Udt = DateTime.Now.AddDays(-1)
                };
                //prodRep.Delete(p);
                prodRep.Update(p1);
                
                //prodRep.Save();
                UnitOfWork.ThreadCommit();
                Console.WriteLine("Update!!");
            //}
            Console.WriteLine("End thread:{0}", Thread.CurrentThread.ManagedThreadId);
        }
Example #32
0
 public RepositoryQuery(Repository <TEntity> repository)
 {
     _repository        = repository;
     _includeProperties =
         new List <Expression <Func <TEntity, object> > >();
 }
Example #33
0
 public void getTournments()
 {
     var watchListList = Repository.GetAll();
 }
 public SearchCustomerScreen(Core.UIItems.WindowItems.Window window, Repository.ScreenRepository screenRepository)
     :
         base(window, screenRepository)
 {
 }
 public Dashboard(Core.UIItems.WindowItems.Window window, Repository.ScreenRepository screenRepository)
     :
         base(window, screenRepository)
 {
 }