Exemplo n.º 1
0
        //Bouton de connection
        private void connectButton_Click(object sender, EventArgs e)
        {
            connectButton.DialogResult = DialogResult.OK;

            //Vérifie les infos
            if (checkInfoValiditie())
            {
                SR2DDatabase db = new SR2DDatabase();

                //Connecte
                SR2DMessages m = db.connect(userTextBox.Text, passwordTextBox.Text, pathTextBox.Text, sourceTextBox.Text, portNumUpDown.Value.ToString());

                if (m == SR2DMessages.SUC_100)
                {
                    form.updateStatutOnWorker("Mise a jour de la base de donnée", 35);

                    if (/*db.updateDatabase(pathTextBox.Text)*/ true)
                    {
                        form.setDatabase(db);

                        this.returnStatut = true;
                        this.Close();
                    }
                }
                else
                {
                    DialogResult failBox = MessageBox.Show("Une erreur est survenue lors de la connection à la base de donnée ! Veuillez vérifier la validité de vos informations de connection.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 2
0
        public userAddForm(usersForm uF, SR2DDatabase db)
        {
            InitializeComponent();

            this.uF = uF;
            this.db = db;

            getRanks();
        }
Exemplo n.º 3
0
        public foodTypeInfoForm(foodTypeForm fTF, SR2DClassBound cB, DataRow refDR)
        {
            InitializeComponent();

            this.fTF   = fTF;
            this.cB    = cB;
            this.db    = cB.db;
            this.refDR = refDR;

            init();
        }
Exemplo n.º 4
0
        public usersForm(mainForm mF, SR2DDatabase db)
        {
            InitializeComponent();

            this.mF = mF;
            this.db = db;

            db.Ds.DatabaseUpdatedEvent += new SR2DDataset.EventHandler(update);

            fillGridView("");
        }
Exemplo n.º 5
0
        public foodAddForm(foodForm fF, SR2DClassBound cB)
        {
            InitializeComponent();

            this.fF = fF;
            this.cB = cB;
            this.db = cB.db;

            foodTypeIDs = new List <int>();

            fill();
        }
Exemplo n.º 6
0
        public foodTypeAddForm(foodTypeForm fTF, SR2DClassBound cB)
        {
            InitializeComponent();

            this.fTF = fTF;
            this.cB  = cB;
            this.db  = cB.db;

            othersFoodTypeIDs = new List <int>();

            fillChListbox();
        }
Exemplo n.º 7
0
        public foodModifyForm(foodForm fF, SR2DClassBound cB, DataRow refDR)
        {
            InitializeComponent();

            this.fF    = fF;
            this.cB    = cB;
            this.db    = cB.db;
            this.refDR = refDR;

            foodTypeIDs = new List <int>();

            fill();
        }
Exemplo n.º 8
0
        public userInfosForm(SR2DClassBound cB, userForm cF, DataRow dr)
        {
            InitializeComponent();

            this.cF             = cF;
            this.cB             = cB;
            this.db             = cB.db;
            this.networkControl = cB.networkControler;

            this.dr = dr;

            load();
        }
Exemplo n.º 9
0
        public foodTypeModifyForm(foodTypeForm fTF, SR2DClassBound cB, DataRow refDR)
        {
            InitializeComponent();

            this.fTF   = fTF;
            this.cB    = cB;
            this.db    = cB.db;
            this.refDR = refDR;

            othersFoodTypeInitialState = new List <CheckState>();
            othersFoodTypeIDs          = new List <int>();

            fill();
        }
Exemplo n.º 10
0
        public foodTypeForm(foodForm fF, SR2DClassBound cB)
        {
            InitializeComponent();

            this.fF = fF;
            this.cB = cB;
            this.db = cB.db;

            db.Ds.DatasetUpdatedEvent += new SR2DDataset.EventHandler(update);

            setServiceMode();

            fillGridView();
        }
Exemplo n.º 11
0
        public userForm(MainForm mF, SR2DClassBound cB)
        {
            InitializeComponent();

            this.mF = mF;

            this.cB             = cB;
            this.db             = cB.db;
            this.networkControl = cB.networkControler;

            fillGridView();

            db.Ds.DatasetUpdatedEvent += new SR2DDataset.EventHandler(update);
        }
Exemplo n.º 12
0
        public MainForm(SR2DClassBound cB, initForm iF)
        {
            InitializeComponent();

            this.cB = cB;

            this.database         = cB.db;
            this.networkControler = cB.networkControler;

            database.Ds.DatasetUpdatedEvent += new SR2DDataset.EventHandler(update);

            updateHUD();

            this.iF = iF;
        }
Exemplo n.º 13
0
        public SR2DNetworkClientControl(int port, string ip, SR2DDatabase db)
        {
            this.ip   = ip;
            this.port = port;
            this.db   = db;

            serverValiditieTimer = new System.Timers.Timer(15000);

            serverValiditieTimer.Elapsed += new ElapsedEventHandler(setDisconnected);

            serverValiditieTimer.Start();

            startClient();

            db.Ds.DatabaseUpdatedEvent += new SR2DDataset.EventHandler(requestUpdate); //Register to database update from user
        }
Exemplo n.º 14
0
        static public string getNextID(string table, SR2DDatabase db)
        {
            DataRowCollection drC = db.Ds.Dataset.Tables[table].Rows;

            int maxID = 0;

            foreach (DataRow dr in drC)
            {
                if (int.Parse(dr.ItemArray[0].ToString()) > maxID)
                {
                    maxID = int.Parse(dr.ItemArray[0].ToString());
                }
            }

            maxID++;

            return(maxID.ToString());
        }
Exemplo n.º 15
0
        //********** END FONCTION INITIALISATION DES FICHIERS **********//

        //********** FONCTION INITIALISATION DE LA BASE DE DONNEE **********//

        public bool initDatabase()
        {
            string defaultConnectionName = hasDefaultConnection();

            if (defaultConnectionName.Split(';')[0] == "true")
            {
                XmlDocument xmlDoc = new XmlDocument();

                xmlDoc.Load(SR2DURLs.connectionXmlFile.getUrlFromRoot()); //Load connection file

                XmlNode root = xmlDoc.DocumentElement;

                XmlNodeList nodeList = root.ChildNodes;

                foreach (XmlNode node in nodeList)
                {
                    if (node.Attributes[0].Value == defaultConnectionName.Split(';')[1])
                    {
                        db = new SR2DDatabase();

                        SR2DMessages m = db.connect(node.ChildNodes[1].Attributes[0].Value, node.ChildNodes[2].Attributes[0].Value, node.ChildNodes[0].Attributes[0].Value, node.ChildNodes[4].Attributes[0].Value, node.ChildNodes[3].Attributes[0].Value);

                        if (m != SR2DMessages.SUC_100)
                        {
                            //??? Rajout modification connection (defaut, ajout , supression ...) ???//

                            writeConsole("Impossible de se connecter à la base de donnée");

                            return(false);
                        }
                    }
                }
            }
            else
            {
                //??? Rajout modification connection (defaut, ajout , supression ...) ???//

                writeConsole("Données de connections invalides");

                return(false);
            }

            return(true);
        }
Exemplo n.º 16
0
        public foodForm(MainForm baseForm, SR2DClassBound cB)
        {
            InitializeComponent();

            this.networkControler = cB.networkControler;

            this.db       = cB.db;
            this.baseForm = baseForm;
            this.cB       = cB;

            this.Height = baseForm.Height - 150;
            this.Width  = baseForm.Width - 200;

            this.CenterToParent();

            db.Ds.DatasetUpdatedEvent += new SR2DDataset.EventHandler(update);

            setServiceMode();

            fillGridView();
        }
Exemplo n.º 17
0
        public ServiceManagerForm(MainForm mF, SR2DClassBound cB)
        {
            InitializeComponent();

            this.cB = cB;
            this.db = cB.db;

            this.mF = mF;

            db.Ds.DatasetUpdatedEvent += new SR2DDataset.EventHandler(update);

            #region INIT_CHARTS
            var mapper = Mappers.Xy <MeasureModel>()
                         .X(model => model.DateTime.Ticks) //use DateTime.Ticks as X
                         .Y(model => model.Value);         //use the value property as Y

            //lets save the mapper globally.
            Charting.For <MeasureModel>(mapper);

            //the ChartValues property will store our values array
            reserv  = new ChartValues <MeasureModel>();
            retired = new ChartValues <MeasureModel>();

            cartesianChart1.Series = new SeriesCollection
            {
                new LineSeries
                {
                    Values         = reserv,
                    PointGeometry  = null,
                    LineSmoothness = 0.5
                }
            };

            cartesianChart1.DataTooltip = null;



            cartesianChart1.AxisX.Add(new Axis
            {
                DisableAnimations = false,
                LabelFormatter    = value => new System.DateTime((long)value).ToString("HH:mm:ss"),
                Separator         = new Separator
                {
                    Step = TimeSpan.FromSeconds(60).Ticks
                }
            });

            cartesianChart1.AxisY.Add(new Axis
            {
                Separator = new Separator
                {
                    Step = 1,
                }
            });

            cartesianChart1.AxisY[0].MinValue = 0;

            SetAxisLimits(System.DateTime.Now, cartesianChart1);

            cartesianChart2.Series = new SeriesCollection
            {
                new LineSeries
                {
                    Values         = retired,
                    PointGeometry  = null,
                    LineSmoothness = 0.5
                }
            };

            cartesianChart2.DataTooltip = null;



            cartesianChart2.AxisX.Add(new Axis
            {
                DisableAnimations = false,
                LabelFormatter    = value => new System.DateTime((long)value).ToString("HH:mm:ss"),
                Separator         = new Separator
                {
                    Step = TimeSpan.FromSeconds(60).Ticks
                }
            });

            cartesianChart2.AxisY.Add(new Axis
            {
                Separator = new Separator
                {
                    Step = 1,
                }
            });

            cartesianChart2.AxisY[0].MinValue = 0;

            SetAxisLimits(System.DateTime.Now, cartesianChart2);

            guiUpdate();

            timer = new Timer
            {
                Interval = 5000
            };
            timer.Tick += timerOnTick;

            timer.Start();

            #endregion

            #region INIT_LIST

            objectListView1.CellEditActivation = ObjectListView.CellEditActivateMode.DoubleClick;
            objectListView1.ShowGroups         = true;
            objectListView1.Sort(2);

            populateDispList();

            updatePrep();

            #endregion

            setServiceMode();
        }
Exemplo n.º 18
0
        private bool threadInit()
        {
            updateStatutOnWorker("Chargement des fichiers", 0);

            if (!checkPathExist(SR2DURLs.mainFolder.getUrlFromRoot()))
            {
                if (!createFolder(SR2DURLs.mainFolder.getUrlFromRoot()))
                {
                    return(false);
                }
            }

            if (!checkFileExist(SR2DURLs.connectionXmlFile.getUrlFromRoot()))
            {
                if (!createConnectionFile())
                {
                    return(false);
                }
            }

            if (!checkFileExist(SR2DURLs.configXmlFile.getUrlFromRoot()))
            {
                if (!createConfigFile())
                {
                    return(false);
                }
            }

            if (!updateConfig(SR2DURLs.configXmlFile.getUrlFromRoot()))
            {
                return(false);
            }

            vars = new SR2DVars();

            updateStatutOnWorker("Chargement des connections", 20);

            string defaultConnectionName = hasDefaultConnection();

            updateStatutOnWorker("Mise a jour des fichiers tiers", 25);

            updateStatutOnWorker("Connection", 30);

            if (defaultConnectionName.Split(';')[0] == "true")
            {
                XmlDocument xmlDoc = new XmlDocument();

                try
                {
                    xmlDoc.Load(SR2DURLs.connectionXmlFile.getUrlFromRoot());

                    XmlNode root = xmlDoc.DocumentElement;

                    XmlNodeList nodeList = root.ChildNodes;

                    foreach (XmlNode node in nodeList)
                    {
                        if (node.Attributes[0].Value == defaultConnectionName.Split(';')[1])
                        {
                            database = new SR2DDatabase();

                            SR2DMessages m = database.connect(node.ChildNodes[1].Attributes[0].Value, node.ChildNodes[2].Attributes[0].Value, node.ChildNodes[0].Attributes[0].Value, node.ChildNodes[4].Attributes[0].Value, node.ChildNodes[3].Attributes[0].Value);

                            if (m != SR2DMessages.SUC_100)
                            {
                                DialogResult failBox = MessageBox.Show("Une erreur est survenue lors de la connection a la base de donnée par defaut !", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);

                                ConnectionForm connectionForm = new ConnectionForm(this);

                                DialogResult r = connectionForm.ShowDialog();

                                while (r != DialogResult.OK || connectionForm.returnStatut != true)
                                {
                                    connectionForm = new ConnectionForm(this);

                                    r = connectionForm.ShowDialog();
                                }



                                Console.WriteLine("conected");
                            }
                            else
                            {
                                updateStatutOnWorker("Mise a jour de la base de donnée", 35);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }
            }
            else
            {
                ConnectionForm connectionForm = new ConnectionForm(this);

                DialogResult r = connectionForm.ShowDialog();

                while (r != DialogResult.OK && connectionForm.returnStatut != true)
                {
                    connectionForm = new ConnectionForm(this);

                    r = connectionForm.ShowDialog();
                }

                Console.WriteLine("connected");
            }

            updateStatutOnWorker("Connection au serveur", 50);

            if (!connectToServer())
            {
                return(false);
            }

            updateStatutOnWorker("Aquisition des données", 70);

            database.initDataset();

            updateStatutOnWorker("Lancement", 100);

            return(true);
        }
Exemplo n.º 19
0
 public void setDatabase(SR2DDatabase db)
 {
     this.database = db;
 }
Exemplo n.º 20
0
 public SR2DClassBound(SR2DDatabase db, SR2DNetworkClientControl controler, SR2DVars vars)
 {
     this.db = db;
     this.networkControler = controler;
     this.vars             = vars;
 }