Esempio n. 1
0
        public bool IsUserAdmin(string name)
        {
            DBWork db    = new DBWork();
            var    users = db.GetUserDataByName(name);

            return(users[0].IsAdmin); // TODO: assert list len >= 1 (= 1 in normal case)
        }
Esempio n. 2
0
        public AdminInterface()
        {
            db = new DBWork();
            InitializeComponent();
            List <SessionPanel> panel     = new List <SessionPanel>();
            List <SessionPanel> panelacrh = new List <SessionPanel>();
            var names = db.getNames();


            foreach (var name in names)
            {
                foreach (var ses in db.getSessionByName(name))
                {
                    if (ses.IsArchived)
                    {
                        panelacrh.Add(new SessionPanel()
                        {
                            Manager = name, Sessions = ses.Session_Name, Session_ID = ses.ID_Session, Archieved = ses.IsArchived
                        });
                    }
                    else
                    {
                        panel.Add(new SessionPanel()
                        {
                            Manager = name, Sessions = ses.Session_Name, Session_ID = ses.ID_Session, Archieved = ses.IsArchived
                        });
                    }
                }
            }

            active.ItemsSource   = panel;
            archived.ItemsSource = panelacrh;
        }
Esempio n. 3
0
 public NewRoute(int sId, List <int> routeNumbers)
 {
     sessionId    = sId;
     RouteNumbers = routeNumbers;
     db           = new DBWork();
     InitializeComponent();
 }
Esempio n. 4
0
        public PrintRoute(int sesID, int rourID)
        {
            InitializeComponent();

            sessionId = sesID;
            routeId   = rourID;
            db        = new DBWork();

            db.getPointBySession(sessionId);

            Gecko.Xpcom.Initialize("Firefox");
            WindowsFormsHost host = new WindowsFormsHost();

            browser = new GeckoWebBrowser();
            browser.DocumentCompleted += (sender, e) => { DrawRoutesOnMap(); };

            host.Child = browser;
            GridWeb.Children.Add(host);
            browser.Navigate(URL);

            setRoutes();
            //point Update
            PrintDialog printDlg = new PrintDialog();

            printDlg.PrintVisual(GridPanel, "GridPrinting");
        }
Esempio n. 5
0
 public ChangeRoute(Route route)
 {
     this.route = route;
     db         = new DBWork();
     hex        = route.Color;
     InitializeComponent();
     RouteNumber.Value = route.RouteNumber;
 }
Esempio n. 6
0
        public ChangeUser(string user)
        {
            db        = new DBWork();
            this.user = user;


            InitializeComponent();
            Name_text.Text = user;
        }
Esempio n. 7
0
        private void AddPointClick(object sender, RoutedEventArgs e)
        {
            string korp = "0";

            if (City.Text == null || Street.Text == "" || House.Text == "")
            {
                System.Windows.MessageBox.Show("Не все обязательные значения введены");
            }
            else
            {
                //pointRN = (int)wayNumber.Value; // получаем введенное значение
                //if (pointNumber < db.FindLastPoint(wayVal + 1, interVal) + 1)
                //    db.Shift(wayVal + 1, interVal, pointNumber);
                if (Corpes.Text != "")
                {
                    korp = Corpes.Text;
                }
                var orderNumber = Order.Text;
                var house       = House.Text;

                var city     = City.Text;
                var street   = Street.Text;
                var interval = interVal;
                var number   = 0; //заглушка?
                //Если номер больше 0, то вызываем метод сдвига
                if (wayNumber.Value > 0)
                {
                    //Метод возвращает (утверждает) номер точки, осуществляя по необходимости сдвиг
                    pointRN = GUI.PointRN.NumberInsert((int)wayNumber.Value, db.GetRoutsBySession(sessionID), db.getPointBySession(sessionID), wayVal);
                }
                //если равен или меньше то ставим в конец
                else
                {
                    DBWork db = new DBWork();
                    pointRN = GUI.PointRN.FirstNumber(db.GetRoutsBySession(sessionID), db.getPointBySession(sessionID), wayVal);
                }


                db.InsertPoint(orderNumber, city, street, house, korp, interval, number, pointRN, sessionID, wayVal);

                DataChangedEventHandler handler = DataChanged;

                if (handler != null)
                {
                    handler(this, new EventArgs());
                }

                this.Close();
            }
        }
Esempio n. 8
0
        public Settings()
        {
            db = new DBWork();
            InitializeComponent();
            List <Man> items = new List <Man>();
            var        names = db.getNames();

            foreach (var name in names)
            {
                items.Add(new Man()
                {
                    PersonName = name
                });
            }
            peopleNames.ItemsSource = items;
        }
Esempio n. 9
0
        private void LoadSessionsList()
        {
            db = new DBWork();
            List <Session> panel = new List <Session>();

            foreach (var ses in db.getSessionByName(userName))
            {
                if (!ses.IsArchived)
                {
                    panel.Add(new Session()
                    {
                        Session_Name = ses.Session_Name,
                        ID_Session   = ses.ID_Session,
                        IsArchived   = ses.IsArchived
                    });
                }
            }

            Session.ItemsSource = panel;
        }
Esempio n. 10
0
        public bool tryLogin(string name, string password)
        {
            DBWork db = new DBWork();

            string salt = CreateSalt(name);

            if (string.IsNullOrEmpty(salt))
            {
                return(false);
            }

            var hashedPassword = HashPassword(password, salt);

            var userData = db.GetUserDataByName(name);

            if (userData[0].Pass == hashedPassword)
            {
                return(true);
            }
            // Ищем в базе соответствие имя/пароль и возвращем сессию с данными, если они есть, и ничего, если их нет.
            return(false);
        }
Esempio n. 11
0
        public EditPoint(Point point, int sessionId)
        {
            this.point = point;
            sessionID  = sessionId;
            db         = new DBWork();

            InitializeComponent();

            addr_street = point.Street;
            addr_house  = point.House;
            addr_korp   = point.Korp;
            order       = point.OrderNumber;
            pointRN     = point.PointType;


            Comment.Text        = point.Comment;
            wayNumber.Value     = point.PointType;
            tB_Addr_street.Text = addr_street;
            tB_Addr_house.Text  = addr_house;
            tB_Addr_korp.Text   = addr_korp;
            tB_order.Text       = order;
        }
Esempio n. 12
0
        private void DeleteSession_Click(object sender, RoutedEventArgs e)
        {
            Button btn = (Button)sender;

            db = new DBWork();
            db.deleteSession(((Session)btn.DataContext).ID_Session);

            List <Session> panel = new List <Session>();

            foreach (var ses in db.getSessionByName(userName))
            {
                if (!ses.IsArchived)
                {
                    panel.Add(new Session()
                    {
                        Session_Name = ses.Session_Name, ID_Session = ses.ID_Session, IsArchived = ses.IsArchived
                    });
                }
            }

            Session.ItemsSource = panel;
        }
Esempio n. 13
0
        private void CreateSession_DataChanged(object sender, EventArgs e)
        {
            List <SessionPanel> panel     = new List <SessionPanel>();
            List <SessionPanel> panelacrh = new List <SessionPanel>();

            db = new DBWork();

            active.ItemsSource   = null;
            archived.ItemsSource = null;

            var names = db.getNames();


            foreach (var name in names)
            {
                var sessions = db.getSessionByName(name);
                foreach (var ses in sessions)
                {
                    if (ses.IsArchived)
                    {
                        panelacrh.Add(new SessionPanel()
                        {
                            Manager = name, Sessions = ses.Session_Name, Session_ID = ses.ID_Session
                        });
                    }
                    else
                    {
                        panel.Add(new SessionPanel()
                        {
                            Manager = name, Sessions = ses.Session_Name, Session_ID = ses.ID_Session
                        });
                    }
                }
            }

            active.ItemsSource   = panel;
            archived.ItemsSource = panelacrh;
        }
Esempio n. 14
0
 public ChangeColor()
 {
     db = new DBWork();
     InitializeComponent();
 }
Esempio n. 15
0
 public MainWindow()
 {
     db = new DBWork();
     InitializeComponent();
 }
Esempio n. 16
0
 public NewPoint()
 {
     db = new DBWork();
     InitializeComponent();
 }
 public ChooseRouteForPrint(int sessionId)
 {
     sesID = sessionId;
     db    = new DBWork();
     InitializeComponent();
 }
Esempio n. 18
0
 public CreateSession()
 {
     db = new DBWork();
     InitializeComponent();
 }
Esempio n. 19
0
        public void setRoutes()
        {
            db     = new DBWork();
            Routes = new ObservableCollection <newRoute> {
            };

            var    Data      = db.getPointBySession(sessionId);
            var    sizeData  = Data.Count;
            string dataPoint = "";

            var dbRoutes = db.GetRoutsBySession(sessionId);

            foreach (var item in dbRoutes)
            {
                if (item.RouteNumber == routeId)
                {
                    List <NewPoints> pointSet1 = new List <NewPoints>();
                    List <NewPoints> pointSet2 = new List <NewPoints>();
                    List <NewPoints> pointSet3 = new List <NewPoints>();
                    List <NewPoints> pointSet4 = new List <NewPoints>();
                    List <NewPoints> pointSet5 = new List <NewPoints>();

                    for (var k = 0; k < sizeData; k++)
                    {
                        var elem     = Data[k];
                        var city     = elem.City;
                        var street   = elem.Street;
                        var house    = elem.House + "";
                        var korp     = elem.Korp + "";
                        var interval = elem.Interval;

                        var route   = elem.ID_Route;
                        var pointID = elem.ID_Point;

                        if (route == item.ID_Route)
                        {
                            string streetAndHouse;
                            if ((korp == "") || (korp == "0"))
                            {
                                streetAndHouse = "ул. " + street + ", " + house;
                                dataPoint      = "   #1" + ": " + streetAndHouse;
                            }
                            else
                            {
                                streetAndHouse = "ул. " + street + ", " + house + " к" + korp;
                                dataPoint      = "   #1" + ": " + streetAndHouse;
                            }

                            var newPoint = new NewPoints
                            {
                                pointId   = elem.ID_Point,
                                pointText = dataPoint,
                                Order     = elem.OrderNumber,
                                Address   = city + ", " + streetAndHouse
                            };
                            switch (interval)
                            {
                            case ("с 9:00 до 12:00"):
                                pointSet1.Add(newPoint);
                                break;

                            case ("с 12:00 до 15:00"):
                                pointSet2.Add(newPoint);
                                break;

                            case ("с 15:00 до 18:00"):
                                pointSet3.Add(newPoint);
                                break;

                            case ("с 18:00 до 21:00"):
                                pointSet4.Add(newPoint);
                                break;

                            case ("с 9:00 до 21:00"):
                                pointSet5.Add(newPoint);
                                break;
                            }
                        }
                    }


                    if (item.RouteNumber == 0)
                    {
                        Routes.Add(new newRoute
                        {
                            routeText  = "Без маршрута",
                            point1     = pointSet1,
                            point2     = pointSet2,
                            point3     = pointSet3,
                            point4     = pointSet4,
                            point5     = pointSet5,
                            GUIroute   = item,
                            RouteColor = item.Color
                        });
                    }
                    else
                    {
                        Routes.Add(new newRoute
                        {
                            routeText  = "Маршрут " + item.RouteNumber,
                            point1     = pointSet1,
                            point2     = pointSet2,
                            point3     = pointSet3,
                            point4     = pointSet4,
                            point5     = pointSet5,
                            GUIroute   = item,
                            RouteColor = item.Color
                        });
                    }
                }
            }
            routesList.ItemsSource = Routes;
        }