Exemplo n.º 1
0
 private void addButton_Click(object sender, EventArgs e)
 {
     string name = contNameTextBox.Text;
     string email = contEmailTextBox.Text;
     string password = contPasswordTextBox.Text;
     int type = 0;
     if (adminRadioButton.Checked) type = 0;
     else if (leaderRadioButton.Checked) type = 1;
     else if (memberRadioButton.Checked) type = 2;
     int teamId = (contTeamComboBox.SelectedItem as Team).Id;
     if ((name != String.Empty) && (email != String.Empty) && (password != String.Empty))
     {
         User usr = new User(name, email, password, new DateTime(), type, teamId, 0, 0, false, false);
         if (connection.AddUser(usr))
         {
             ShowNotifyMessage("Utilizatorul a fost adăugat cu succes!", true);
             contNameTextBox.Text = String.Empty;
             contEmailTextBox.Text = String.Empty;
             contPasswordTextBox.Text = String.Empty;
             contNameTextBox.Focus();
         }
         else
         {
             ShowNotifyMessage("Exista deja un utilizator cu același email!", false);
             contEmailTextBox.Focus();
             contEmailTextBox.SelectAll();
         }
     }
     else
     {
         ShowNotifyMessage("Trebuie să completezi toate câmpurile!", false);
         contNameTextBox.Focus();
     }
 }
Exemplo n.º 2
0
 public EmployeesWindow(User user, Conexiune connection)
 {
     InitializeComponent();
     this.connection = connection;
     this.user = user;
     unknown = DowMediaApplication.Properties.Resources.unknown as Image;
 }
Exemplo n.º 3
0
 public WorkWindow(User user, LoginWindow logWin, Conexiune conn)
 {
     InitializeComponent();
     SetColors();
     this.connection = conn;
     this.loginWindow = logWin;
     this.user = user;
     toolTip = new ToolTip();
     toolTip.IsBalloon = true;
     manageLabel.Visible = (user.Type == (int)UserType.Admin);
     myActButton.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255);
     teamActButton.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255);
     projectsButton.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255);
     taskButton.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255);
     InitializePanelNo1();//activitatile mele
     InitializePanelNo2();//activitatile echipei
     InitializePanelNo3();//proiecte
     InitializePanelNo4();//task-uri
     InitializePanelNo5();//profil
     ChangeColorShowPanel(1);//selectez primul panel cand se deschide forma
     /*-----preluare setari-----*/
     int inactiv = 300;//default
     bool show = true;//default
     if (File.Exists("settings.ini"))
     {
         StreamReader fin = new StreamReader("settings.ini");
         string line;
         while ((line = fin.ReadLine()) != null)
         {
             int poz = line.IndexOf('=');
             if (line.Contains(settings[0]))
                 inactiv = Convert.ToInt32(line.Substring(poz + 1));
             else if (line.Contains(settings[1]))
                 show = Convert.ToBoolean(line.Substring(poz + 1));
         }
         fin.Close();
     }
     empWindow = new EmployeesWindow(user, connection);
     empWindow.Show();
     showEmpWindowCheckBox.Checked = show;
     inactivTimeValue = inactiv;
     this.BringToFront();
     this.Focus();
 }
Exemplo n.º 4
0
 private void timer_Tick(object sender, EventArgs e)
 {
     loading++;
     loadingPictureBox.BackgroundImage = img[loading % 8];
     //this.Icon = Icon.ExtractAssociatedIcon(@"D:\Rotation\Rotate" + (loading % 8) + ".ico");
     if (loading == 24)
     {
         timer.Stop();
         loading = -1;
         loadingPictureBox.Visible = false;
         try
         {
             string email = emailTextBox.Text;
             string parola = parolaTextBox.Text;
             user = conexiune.Login(email, parola);
             if (user != null)
             {
                 this.Hide();
                 WorkWindow ww = new WorkWindow(user, this, conexiune);
                 ww.Show();
             }
             else
             {
                 string text = "Ai greșit adresa de email sau parola. Incearcă din nou!";
                 string caption = "EROARE";
                 MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                 emailTextBox.Focus();
             }
         }
         catch
         {
             MessageBox.Show("A apărut o eroare! Te rugăm să încerci mai târziu!");
         }
         finally
         {
             this.Enabled = true;
         }
     }
 }
Exemplo n.º 5
0
 public void Logout(User user, bool started)
 {
     string query = "UPDATE user SET worktime = @worktime, pausetime = @pausetime, status = @status WHERE email = @email";
     MySqlCommand command = new MySqlCommand(query, connection);
     command.Parameters.AddWithValue("@worktime", user.Worktime);
     command.Parameters.AddWithValue("@pausetime", user.Pausetime);
     command.Parameters.AddWithValue("@status", user.Status);
     command.Parameters.AddWithValue("@email", user.Email);
     command.ExecuteNonQuery();
     if (started)
     {
         //updatez ultima activitate
         query = "SELECT * FROM activity WHERE user_id = @user_id ORDER BY id DESC LIMIT 1";
         command = new MySqlCommand(query, connection);
         command.Parameters.AddWithValue("@user_id", user.Id);
         DataSet dataset = new DataSet();
         MySqlDataAdapter adapter = new MySqlDataAdapter(command);
         adapter.Fill(dataset);
         if (dataset.Tables[0].Rows.Count > 0)
         {
             DataRow row = dataset.Tables[0].Rows[0];
             /*----- preiau datele pentru update -----*/
             int id = Convert.ToInt32(row["id"].ToString());
             DateTime startTime = Convert.ToDateTime(row["start_time"].ToString());
             long duration = Convert.ToInt64(row["duration"].ToString());
             long newDuration = (long)((TimeSpan)(DateTime.Now - startTime)).TotalSeconds;
             /*----- fac update-ul -----*/
             query = "UPDATE activity SET duration = @newDuration WHERE id = @id";
             command = new MySqlCommand(query, connection);
             command.Parameters.AddWithValue("@newDuration", newDuration);
             command.Parameters.AddWithValue("@id", id);
             command.ExecuteNonQuery();
         }
     }
     command.Dispose();
 }
Exemplo n.º 6
0
 public bool IsEqualTo(User A)
 {
     return ((this.Id == A.Id) && (this.Email == A.Email));
 }
Exemplo n.º 7
0
 public void ProfileUpdate(User user, ProfileUpdateType type)
 {
     string query;
     MySqlParameter parameter;
     if (type == ProfileUpdateType.NameUpdate)
     {
         query = "UPDATE user SET name = @name WHERE id = @id";
         parameter = new MySqlParameter("@name", user.Name);
     }
     else if (type == ProfileUpdateType.PasswordUpdate)
     {
         query = "UPDATE user SET password = @password WHERE id = @id";
         parameter = new MySqlParameter("@password", user.Password);
     }
     else// if(type == ProfileUpdateType.PhotoUpdate)
     {
         query = "UPDATE user SET image = @image WHERE id = @id";
         parameter = new MySqlParameter("@image", user.Image);
     }
     MySqlCommand command = new MySqlCommand(query, connection);
     command.Parameters.Add(parameter);
     command.Parameters.AddWithValue("@id", user.Id);
     command.ExecuteNonQuery();
     command.Dispose();
 }
Exemplo n.º 8
0
 public List<User> TeamMembers(User user)
 {
     List<User> L = new List<User>();
     string query = "SELECT * FROM user WHERE team_id = @team_id ORDER BY name ASC";
     MySqlCommand command = new MySqlCommand(query, connection);
     command.Parameters.AddWithValue("@team_id", user.Team_id);
     DataSet dataset = new DataSet();
     MySqlDataAdapter adapter = new MySqlDataAdapter(command);
     adapter.Fill(dataset);
     foreach (DataRow row in dataset.Tables[0].Rows)
     {
         int id = Convert.ToInt32(row["id"].ToString());
         string name = Convert.ToString(row["name"]);
         string email = Convert.ToString(row["email"]);
         string password = Convert.ToString(row["password"]);
         DateTime login = Convert.ToDateTime(row["last_login"]);
         int type = Convert.ToInt32(row["type"].ToString());
         int team_id = Convert.ToInt32(row["team_id"].ToString());
         long worktime = Convert.ToInt64(row["worktime"].ToString());
         long pausetime = Convert.ToInt64(row["pausetime"].ToString());
         bool status = Convert.ToBoolean(row["status"].ToString());
         bool image = Convert.ToBoolean(row["image"].ToString());
         L.Add(new User(id, name, email, password, login, type, team_id, worktime, pausetime, status, image));
     }
     command.Dispose();
     adapter.Dispose();
     dataset.Dispose();
     return L;
 }
Exemplo n.º 9
0
 public bool AddUser(User user)
 {
     if (UserAlreadyExists(user.Email))
         return false;
     string query = "INSERT INTO user(name, email, password, last_login, type, team_id, worktime, pausetime, status, image) VALUES (@name, @email, @password, @last_login, @type, @team_id, @worktime, @pausetime, @status, @image)";
     MySqlCommand command = new MySqlCommand(query, connection);
     command.Parameters.AddWithValue("@name", user.Name);
     command.Parameters.AddWithValue("@email", user.Email);
     command.Parameters.AddWithValue("@password", user.Password);
     command.Parameters.AddWithValue("@last_login", user.LoginTime);
     command.Parameters.AddWithValue("@type", user.Type);
     command.Parameters.AddWithValue("@team_id", user.Team_id);
     command.Parameters.AddWithValue("@worktime", 0);
     command.Parameters.AddWithValue("@pausetime", 0);
     command.Parameters.AddWithValue("@status", false);
     command.Parameters.AddWithValue("@image", false);
     command.ExecuteNonQuery();
     command.Dispose();
     return true;
 }