private void projectUsersListBox_SelectedIndexChanged(object sender, EventArgs e) { projectInfoPanel.Controls.Clear(); Project p = projectInfoListBox.SelectedItem as Project; User u = projectUsersListBox.SelectedItem as User; if (p != null && u != null) { workProjInfoLabel.Text = ConvertTime(0); pauseProjInfoLabel.Text = ConvertTime(0); long work = 0, pause = 0; List<ExtractInfo> actList = connection.WorkOfUserAtProject(p.Id, u.Id); int n = actList.Count; for (int i = 0; i < n; i++) { ExtractInfo ob = actList[i]; ActivityBox box = new ActivityBox(); box.BodyText = ob.Description; box.HeaderText = ob.ProjectName + " (" + ConvertTime(ob.Duration) + ")"; string moment = BoxDateTime(ob.StartTime); box.DateText = moment.Substring(0, 5); box.TimeText = moment.Substring(6); box.HeaderColor = (ob.Type == 0) ? Color.Red : Color.ForestGreen; box.Location = new Point(3, 3 + i * 85); projectInfoPanel.Controls.Add(box.ShowControl); work += (ob.Type == 1) ? ob.Duration : 0; pause += (ob.Type == 0) ? ob.Duration : 0; } workProjInfoLabel.Text = ConvertTime(work); pauseProjInfoLabel.Text = ConvertTime(pause); projectInfoPanel.Controls[n - 1].Focus(); } }
private void ShowMemberActivity() { User member = teamListBox.SelectedItem as User; teamActPanel.Controls.Clear(); DateTime date = teamActDTP1.Value.Date; DateTime dt1 = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0); date = teamActDTP2.Value.Date; DateTime dt2 = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59); List<ExtractInfo> L = connection.ActivityExtract(member.Id, dt1, dt2); memberWorkLabel.Text = "0h 0' 0\""; memberPauseLabel.Text = "0h 0' 0\""; if (L == null) { string msg = " nu a desfășurat nicio activitate in această perioadă."; teamActMessageLabel.Text = member.Name + msg; teamActMessageLabel.Visible = true; } else { long work = 0, pause = 0; teamActMessageLabel.Visible = false; for (int i = 0; i < L.Count; i++) { ExtractInfo ob = L[i]; ActivityBox box = new ActivityBox(); box.BodyText = ob.Description; box.HeaderText = ob.ProjectName + " (" + ConvertTime(ob.Duration) + ")"; string moment = BoxDateTime(ob.StartTime); box.DateText = moment.Substring(0, 5); box.TimeText = moment.Substring(6); box.HeaderColor = (ob.Type == 0) ? Color.Red : Color.ForestGreen; box.Location = new Point(3, 3 + i * 85); teamActPanel.Controls.Add(box.ShowControl); work = work + ((ob.Type == 1) ? ob.Duration : 0); pause = pause + ((ob.Type == 0) ? ob.Duration : 0); } teamActPanel.Controls[teamActPanel.Controls.Count - 1].Focus(); //#region Functii pentru panelNo1, "Activitatile echipei" memberWorkLabel.Text = ConvertTime(work); memberPauseLabel.Text = ConvertTime(pause); } }
//Cauta private void myActSearchButton_Click(object sender, EventArgs e) { myActPanel.Controls.Clear(); DateTime date = myActDTP1.Value.Date; DateTime dt1 = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0); date = myActDTP2.Value.Date; DateTime dt2 = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59); List<ExtractInfo> L = connection.ActivityExtract(user.Id, dt1, dt2); if (L == null) ShowNotifyMessage("Nu ai desfășurat nicio activitate in această perioadă.", 0); else { for (int i = 0; i < L.Count; i++) { ExtractInfo ob = L[i]; ActivityBox box = new ActivityBox(); DateTime st = ob.StartTime; box.BodyText = ob.Description; box.HeaderText = ob.ProjectName + " (" + ConvertTime(ob.Duration) + ")"; string moment = BoxDateTime(ob.StartTime); box.DateText = moment.Substring(0, 5); box.TimeText = moment.Substring(6); box.HeaderColor = (ob.Type == 0) ? Color.Red : Color.ForestGreen; box.Location = new Point(3, 3 + i * 85); myActPanel.Controls.Add(box.ShowControl); } myActPanel.Controls[myActPanel.Controls.Count - 1].Focus(); } }
//Salveaza private void saveActivityButton_Click(object sender, EventArgs e) { if (messageRichTextBox.Text.Length == 0) { ShowNotifyMessage("Completeaza rubrica pentru mesaj.", 1); messageRichTextBox.Focus(); return; } if (!activityStarted) idleTimer.Start(); chooseButton.Enabled = (choose == 0); saveActivityButton.Enabled = false; ActivityBox box = new ActivityBox(); Activity activity = new Activity(); activity.User_id = user.Id; activity.Project_id = selectedProject.Id; activity.Start_time = DateTime.Now; activity.Description = messageRichTextBox.Text.Trim(); activity.Duration = 0; activity.Task_id = 0; if (choose == 1)//START { activityStarted = true; activity.Type = 1; connection.ActivityInsert(activity); workTimer.Start();//merge munca pauseTimer.Stop();//nu merge pauza statusProjectLabel.Text = "ACTIV"; statusProjectLabel.ForeColor = Color.Green; box.HeaderColor = Color.ForestGreen; box.HeaderText = selectedProject.Name;// +nowTime; startButton.Enabled = true; pauseButton.Enabled = true; } else//PAUZA { activityStarted = false;//cod nou!!! activity.Type = 0; connection.ActivityInsert(activity); workTimer.Stop();//merge munca pauseTimer.Start();//nu merge pauza statusProjectLabel.Text = "PAUZĂ"; statusProjectLabel.ForeColor = Color.Red; box.HeaderColor = Color.Red; box.HeaderText = "PAUZĂ";// +nowTime; startButton.Enabled = true; pauseButton.Enabled = true; } string moment = BoxDateTime(DateTime.Now); box.DateText = moment.Substring(0, 5); box.TimeText = moment.Substring(6); box.BodyText = messageRichTextBox.Text.Trim(); int count = myActPanel.Controls.Count; Point p1 = new Point(3, 3 + count * 85); Point p2 = new Point(3, 3 + (nBox++) * 85); box.Location = (count > nBox) ? p1 : p2; myActPanel.Controls.Add(box.ShowControl); myActPanel.Controls[myActPanel.Controls.Count - 1].Focus(); messageRichTextBox.Text = String.Empty; }
//Timerul pentru systemul de inactivitate private void idleTimer_Tick(object sender, EventArgs e) { TagLastInputInfo lastInput = new TagLastInputInfo(); lastInput.cbSize = (uint)Marshal.SizeOf(lastInput); lastInput.dwTime = 0; if (GetLastInputInfo(ref lastInput)) { int idleTime = Environment.TickCount - lastInput.dwTime; //label14.Text = ((float)(idleTime / 1000.0)).ToString() + " s"; bool passed = (int)(idleTime / 1000.0) > inactivTimeValue; if (activityStarted && passed) { idleTime = 0; activityStarted = false; idleTimer.Stop(); connection.ActivityStop(user.Id, inactivTimeValue); chooseButton.Enabled = true; saveActivityButton.Enabled = false; ActivityBox box = new ActivityBox(); Activity activity = new Activity(); activity.User_id = user.Id; activity.Project_id = selectedProject.Id; activity.Start_time = DateTime.Now; activity.Description = string.Format("[Aplicatie]: Activitate oprită. Motiv: inactiv > {0} minute", inactivTimeValue / 60); activity.Duration = 0; activity.Task_id = 0; activity.Type = 0; connection.ActivityInsert(activity); workTimer.Stop(); pauseTimer.Start(); statusProjectLabel.Text = "PAUZĂ"; statusProjectLabel.ForeColor = Color.Red; box.HeaderColor = Color.Red; box.HeaderText = "PAUZĂ";// +nowTime; startButton.Enabled = true; pauseButton.Enabled = true; string moment = BoxDateTime(DateTime.Now); box.DateText = moment.Substring(0, 5); box.TimeText = moment.Substring(6); box.BodyText = string.Format("[Aplicatie]: Activitate oprită. Motiv: inactiv > {0} minute", inactivTimeValue / 60); int count = myActPanel.Controls.Count; Point p1 = new Point(3, 3 + count * 85); Point p2 = new Point(3, 3 + (nBox++) * 85); box.Location = (count > nBox) ? p1 : p2; myActPanel.Controls.Add(box.ShowControl); myActPanel.Controls[myActPanel.Controls.Count - 1].Focus(); } } }