예제 #1
0
        private void GetLog()
        {
            if (filedestination != null || filedestination.Length > 0)
            {
                QueryManager qMgr    = new QueryManager();
                DataTable    LogDict = qMgr.RetrieveData("TimeLog", "DeviceName", "'" + comboBox1.SelectedItem.ToString() + "'");

                using (StreamWriter file = new StreamWriter(filedestination))
                {
                    string header = "User,Date Used, Time On, Time Off, Time Used";
                    file.WriteLine("Log for: " + comboBox1.SelectedItem.ToString());
                    file.WriteLine(header);
                    foreach (DataRow log in LogDict.Rows)
                    {
                        string[] propertylist = new string[5];
                        propertylist[0] = log["UserName"].ToString();
                        propertylist[1] = log["DateUsed"].ToString();
                        propertylist[2] = log["TimeOn"].ToString();
                        propertylist[3] = log["TimeOff"].ToString();;
                        propertylist[4] = log["TimeUsed"].ToString();
                        string line = String.Join(",", propertylist);
                        file.WriteLine(line);
                    }
                }
            }
        }
예제 #2
0
        private void GetDevices()
        {
            DataTable LDevDict = qMgr.RetrieveData("Instruments");

            foreach (DataRow row in LDevDict.Rows)
            {
                comboBox1.Items.Add(row["DeviceName"].ToString());
            }
        }
        private void CalcTotalDevUsageTime(string deviceID)
        {
            QueryManager qMgr = new QueryManager();
            DataTable    instrument_details = qMgr.RetrieveData("Instruments", "DeviceID", deviceID);
            DataTable    timelogs           = qMgr.RetrieveData("Timelog", "DeviceID", deviceID);
            TimeSpan     TotalTimeUsed      = new TimeSpan();

            foreach (DataRow instrument in instrument_details.Rows)
            {
                foreach (DataRow row in timelogs.Rows)
                {
                    if (Convert.ToDateTime(row["DateUsed"].ToString()) >= Convert.ToDateTime(instrument["DateofLastService"].ToString()))
                    {
                        TotalTimeUsed += TimeSpan.Parse(row["TimeUsed"].ToString());
                    }
                }
                MessageBox.Show(instrument["DeviceName"].ToString() + " has been used for a total of " + TotalTimeUsed.Hours + " hour(s) and " + TotalTimeUsed.Minutes + " min");
            }
        }
        private void DevToMonitor()
        {
            QueryManager qMgr = new QueryManager();
            DataTable    returnedrows_devices = qMgr.RetrieveData("Instruments");

            if (returnedrows_devices != null)
            {
                foreach (DataRow row in returnedrows_devices.Rows)
                {
                    DeviceIDToMon.Add(row["DeviceID"].ToString());
                    DeviceNameToMon.Add(row["DeviceName"].ToString());
                }
            }
        }
예제 #5
0
        private void PrepareDataGrid(string devicename)
        {
            QueryManager qMgr = new QueryManager();

            dataGridView1.DataSource = qMgr.RetrieveData("TimeLog", "DeviceName", "'" + comboBox1.SelectedItem.ToString() + "'");
        }