Exemplo n.º 1
0
        public ReviewForm(LabroomForm labroomForm)
        {
            InitializeComponent();

            Labroom = labroomForm;
            labmemberFillLabel.Text = Labroom.labmemberName;
            dateFillLabel.Text = DateTime.Now.ToLongDateString();

            foreach (string labroom in Labroom.Data.Keys)
            {
                // add each new ReviewBox to Data field
                Data[labroom] = new ReviewBox[8];
                int i = 0;
                try {
                    foreach (LogData log in Labroom.Data[labroom])
                        Data[labroom][i++] = new ReviewBox(log);
                }
                catch (KeyNotFoundException e) {
                    //skip if no data input for that labroom
                }

                if (labroom == "W715") {
                    foreach (ReviewBox rB in Data[labroom])
                        W715Panel.Controls.Add(rB);
                }
                else if (labroom == "W716") {
                    foreach (ReviewBox rB in Data[labroom])
                        W716Panel.Controls.Add(rB);
                }
                else if (labroom == "W718") {
                    foreach (ReviewBox rB in Data[labroom])
                        W718Panel.Controls.Add(rB);
                }
            }
        }
Exemplo n.º 2
0
        public ReviewForm(LabroomForm labroomForm)
        {
            InitializeComponent();

            Labroom = labroomForm;
            labmemberFillLabel.Text = Labroom.labmemberName;
            dateFillLabel.Text = DateTime.Now.ToLongDateString();

            foreach (LogData d in Labroom.Data)
            {
                if (d.Labroom == 1)
                    labroom1Panel.Controls.Add(new ReviewBox(d));
                else if (d.Labroom == 2)
                    labroom2Panel.Controls.Add(new ReviewBox(d));
            }
        }
Exemplo n.º 3
0
        public LogForm(LabroomForm labroomForm, string labroom, LoginForm login)
        {
            InitializeComponent();

            this.Login = login;
            this.Labroom = labroomForm;
            this.labroom = labroom;

            labmemberFillLabel.Text = Login.name[0] + " " + Login.name[1];
            checkinFillLabel.Text = this.labroom + ", " + DateTime.Now.ToShortTimeString()
                                                 +  " " + DateTime.Now.ToLongDateString();
            // get monkey data from config
            Dictionary<string, Dictionary<string, string>> monkeys = Login.config.monkey_data;

            // get monkeys for this labroom
            var monks = from monkey in monkeys
                        where monkey.Value["room"].Equals(this.labroom)
                        orderby monkey.Value["station"] ascending
                        select monkey;

            int index = 0;
            numMonks = monks.ToArray().Length;
            int half = numMonks / 2;

            // GET ORDERING RIGHT
            foreach (var m in monks)
            {
                LogBox monkLogbox = new LogBox(m.Key, m.Value["station"], this.labroom, Login.config);

                //add half to left, half to right
                if (index < half)
                    this.leftLayoutPanel.Controls.Add(monkLogbox);
                else
                    this.rightLayoutPanel.Controls.Add(monkLogbox);
                index++;
            }
        }
Exemplo n.º 4
0
        public LogForm(LabroomForm labroom, int roomNum, LoginForm login)
        {
            InitializeComponent();

            Login = login;
            Labroom = labroom;
            labroomNum = roomNum;

            labmemberFillLabel.Text = Login.name[0] + " " + Login.name[1];
            checkinFillLabel.Text = "Labroom " + labroomNum.ToString()
                + ", " + DateTime.Now.ToShortTimeString()
                + " " + DateTime.Now.ToLongDateString();

            PCRLLogbookDBDataSet1.MonkeyDataTable monkeys = this.monkeyTableAdapter.GetData();

            var monks =
                from monkey in monkeys
                where monkey.LabRoom.Equals(labroomNum)
                select monkey;

            int index = 0;
            numMonks = monks.ToArray().Length;
            int half = numMonks / 2;

            foreach (var m in monks)
            {
                LogBox monkLogbox = new LogBox(m.MID, Convert.ToInt16(m.Station), labroomNum);

                //add half to left, half to right
                if (index < half)
                    this.leftLayoutPanel.Controls.Add(monkLogbox);
                else
                    this.rightLayoutPanel.Controls.Add(monkLogbox);
                index++;
            }
        }
Exemplo n.º 5
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            // reload config upon login, so to update any changes
            string json = "";
            try {
                using (StreamReader sr = new StreamReader(config_path)) {
                    json = sr.ReadToEnd();
                }
            } catch (Exception exp) {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(exp.Message);
            }
            config = JsonConvert.DeserializeObject<Config>(json);

            //check login
            if (usernameTextbox.Text.Equals(string.Empty)) {
                MessageBox.Show("Please fill in username and password fields.");
                return;
            }

            //set db directory
            db_dir = config.db_file;

            username = usernameTextbox.Text;
            password = passwordTextbox.Text;

            Dictionary<string, Dictionary<string, string>> labmembers = config.labmember_data;

            var user =
                from labmember in labmembers
                where labmember.Key.Equals(username) && labmember.Value["password"].Equals(password)
                select labmember;

            if (!user.Any())
                MessageBox.Show("Invalid username or password.\nPlease proceed to create an account.");
            else
            {
                name[0] = user.First().Value["first"];
                name[1] = user.First().Value["last"];
                LabroomForm labroomForm = new LabroomForm(this);
                labroomForm.Show();
                Hide();
            }
        }
Exemplo n.º 6
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            if (usernameTextbox.Text.Equals(string.Empty)) {
                MessageBox.Show("Please fill in username and password fields.");
                return;
            }

            user = usernameTextbox.Text;
            password = passwordTextbox.Text;

            PCRLLogbookDBDataSet1.LabMemberDataTable labmembers = this.labMemberTableAdapter.GetData();

            var users =
                from labmember in labmembers
                where labmember.LabMember.Equals(user)
                select labmember.LabMember;

            if (!users.Any())
                MessageBox.Show("Invalid username.\nPlease proceed to create an account.");

            var passwords =
                from labmember in labmembers
                where labmember.LabMember.Equals(user)
                select labmember.Password;

            foreach (string pw in passwords)
            {
                if (pw.Equals(password))
                {
                    var first =
                        from labmember in labmembers
                        where labmember.LabMember.Equals(user)
                        select labmember.First;
                    var last =
                        from labmember in labmembers
                        where labmember.LabMember.Equals(user)
                        select labmember.Last;

                    foreach (string f in first)
                    {
                        foreach (string l in last)
                        {
                            name[0] = f;
                            name[1] = l;
                        }
                    }

                    LabroomForm labroomForm = new LabroomForm(this);
                    labroomForm.Show();
                    Hide();
                }
                else
                {
                    MessageBox.Show("\tInvalid password.");
                }
            }
        }