コード例 #1
0
 public void Convert_DB_Users(DB_Users db_users, int index)
 {
     this.Site_User_ID     = db_users.Site_User_ID[index];
     this.Site_ID          = db_users.Site_ID[index];
     this.User_ID          = db_users.User_ID[index];
     this.User_Name        = db_users.User_Name[index];
     this.View_Resources   = db_users.View_Resources[index];
     this.Add_Resources    = db_users.Add_Resources[index];
     this.Modify_Resources = db_users.Modify_Resources[index];
     this.Del_Resources    = db_users.Del_Resources[index];
     this.View_Tickets     = db_users.View_Tickets[index];
     this.Add_Tickets      = db_users.Add_Tickets[index];
     this.Mark_Delete      = db_users.Mark_Delete[index];
     this.Changed          = false;
 }
コード例 #2
0
        //
        //  Function:   private void btn_Save_Clicked(object sender, RoutedEventArgs e)
        //
        //  Arguments:  object sender = object that called function (Short_Name textbox)
        //              RoutedEventArgs e = arguments for the event
        //
        //  Purpose:    Save current changes to the site users after confirmation from a messagebox
        //
        private void btn_Save_Clicked(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Do you want to save your changes?", "Save Changes", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes)
            {
                DB_Users changed_users = new DB_Users();
                changed_users.Initialize();

                for (int i = 0; i < View_Users.Count; i++)
                {
                    if (View_Users[i].Changed == true || View_Users[i].Mark_Delete == true)
                    {
                        changed_users.Site_User_ID.Add(View_Users[i].Site_User_ID);
                        changed_users.Site_ID.Add(csite.site_info.Site_ID);
                        changed_users.User_ID.Add(View_Users[i].User_ID);
                        changed_users.View_Resources.Add(View_Users[i].View_Resources);
                        changed_users.Add_Resources.Add(View_Users[i].Add_Resources);
                        changed_users.Modify_Resources.Add(View_Users[i].Modify_Resources);
                        changed_users.Del_Resources.Add(View_Users[i].Del_Resources);
                        changed_users.View_Tickets.Add(View_Users[i].View_Tickets);
                        changed_users.Add_Tickets.Add(View_Users[i].Add_Tickets);
                        changed_users.Mark_Delete.Add(View_Users[i].Mark_Delete);
                    }
                }
                if (changed_users.Save_List(1, csite.site_info.Site_ID) == true)
                {
                    MessageBox.Show("Changes Successfully Saved", "Success", MessageBoxButton.OK, MessageBoxImage.Information);

                    Init_Complete = false;
                    Make_User_List(Mode);
                    Init_Complete = true;
                    csite.changed = true;

                    // Update the current users options
                    for (int i = 0; i < View_Users.Count; i++)
                    {
                        if (View_Users[i].User_ID == cuser_info.User_ID)
                        {
                            cuser.Update_Current_User(View_Users[i]);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Changes Could Not Be Saved", "Failed To Save", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
コード例 #3
0
        public Users Get_User_Settings(long site_id, int user_id)
        {
            DB_Users users      = new DB_Users();
            Users    blank_user = new Users();

            users.Get_List(1, site_id);
            for (int q = 0; q < users.User_Name.Count; q++)
            {
                Users user = new Users();
                user.Convert_DB_Users(users, q);
                if (user.User_ID == user_id)
                {
                    return(user);
                }
            }
            return(blank_user);
        }
コード例 #4
0
        private void Generate_User_List(List <Users> exclude_users)
        {
            DB_Users all_users = new DB_Users();

            all_users.Get_List(0);

            for (int i = 0; i < exclude_users.Count; i++)
            {
                int x = all_users.User_ID.IndexOf(exclude_users[i].User_ID);
                if (x != -1)
                {
                    all_users.Remove_User(0, x);
                }
            }

            avail_users = new ObservableCollection <DB_Users>();


            avail_users.Add(all_users);
        }
コード例 #5
0
        //
        //  Function:   private void Make_User_List(int mode)
        //
        //  Arguments:  int mode = Mode of operation (0 = All Users, 1 = Just this site's users
        //
        //  Purpose:    Display the User List for a new or existing site
        //
        private void Make_User_List(int mode)
        {
            View_Users.Clear();
            DB_Users users = new DB_Users();

            if (mode == 0)
            {
                users.Get_List(0);
            }
            else
            {
                users.Get_List(1, csite.site_info.Site_ID);
            }
            for (int i = 0; i < users.User_Name.Count; i++)
            {
                Users user = new Users();
                user.PropertyChanged += User_PropertyChanged;
                user.Convert_DB_Users(users, i);
                View_Users.Add(user);
                View_Users[i].Changed     = false;
                View_Users[i].Mark_Delete = false;
            }
            Changes_Made = false;
        }
コード例 #6
0
        public void Load_Task_Details(long Ticket_ID, int User_ID, bool All_Tasks)
        {
            int      task_count = 0;
            DB_Users users      = new DB_Users();

            users.Get_List(0);

            // Read all the tickets for the assigned ticket ID
            active_tasks.Clear();

            // Open the database and retrieve tickets for the current user or all of them if all is selected
            string connString = SQLConnString;

            // Query the tickets for this site for this user
            StringBuilder query = new StringBuilder("SELECT * FROM ");

            query.Append(tblTasks);
            query.Append(" WHERE Ticket_ID = '");
            query.Append(Ticket_ID);
            query.Append("'");
            // If select all is not enabled, only show this users tickets
            if (All_Tasks == false)
            {
                query.Append(" AND (Assigned_User_ID = '");
                query.Append(User_ID);
                query.Append("' OR Creator_ID = '");
                query.Append(User_ID);
                query.Append("')");
            }

            // Read all the tasks associated with this ticket
            using (SqlConnection sqlCon = new SqlConnection(connString))
            {
                sqlCon.Open();
                SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                using SqlDataReader reader = SqlCmd.ExecuteReader();
                while (reader.Read())
                {
                    Tickets_Tasks ticket_task = new Tickets_Tasks();

                    ticket_task.Site_ID        = ((long)reader[0]);
                    ticket_task.Ticket_ID      = ((long)reader[1]);
                    ticket_task.Ticket_Task_ID = ((long)reader[2]);
                    ticket_task.Creator_ID     = ((int)reader[3]);
                    for (int i = 0; i < users.User_ID.Count; i++)
                    {
                        if (users.User_ID[i] == ticket_task.Creator_ID)
                        {
                            ticket_task.Creator = users.User_Name[i];
                        }
                    }
                    if (!DBNull.Value.Equals(reader[4]))
                    {
                        ticket_task.Created_On = ((DateTime)reader[4]);
                    }
                    if (!DBNull.Value.Equals(reader[5]))
                    {
                        ticket_task.Task_Status = ((int)reader[5]);
                    }
                    if (!DBNull.Value.Equals(reader[6]))
                    {
                        ticket_task.Task_ID = ((long)reader[6]);
                    }
                    if (!DBNull.Value.Equals(reader[7]))
                    {
                        ticket_task.Priority = ((int)reader[7]);
                    }
                    if (!DBNull.Value.Equals(reader[8]))
                    {
                        ticket_task.Task_Overview = ((string)reader[8]);
                    }
                    if (!DBNull.Value.Equals(reader[9]))
                    {
                        ticket_task.Task_Details = ((string)reader[9]);
                    }
                    if (!DBNull.Value.Equals(reader[10]))
                    {
                        ticket_task.Assigned_User_ID = ((int)reader[10]);
                    }
                    for (int i = 0; i < users.User_ID.Count; i++)
                    {
                        if (users.User_ID[i] == ticket_task.Assigned_User_ID)
                        {
                            ticket_task.Assigned_User = users.User_Name[i];
                        }
                    }
                    if (!DBNull.Value.Equals(reader[11]))
                    {
                        ticket_task.Progress = ((int)reader[11]);
                    }
                    if (!DBNull.Value.Equals(reader[12]))
                    {
                        ticket_task.Due_On = ((DateTime)reader[12]);
                    }
                    if (!DBNull.Value.Equals(reader[13]))
                    {
                        ticket_task.Started_TS = ((DateTime)reader[13]);
                    }
                    if (!DBNull.Value.Equals(reader[14]))
                    {
                        ticket_task.Completed_TS = ((DateTime)reader[14]);
                    }
                    if (!DBNull.Value.Equals(reader[15]))
                    {
                        ticket_task.Notes = ((string)reader[15]);
                    }
                    if (!DBNull.Value.Equals(reader[16]))
                    {
                        ticket_task.Alarm1_Enabled = ((bool)reader[16]);
                    }
                    if (!DBNull.Value.Equals(reader[17]))
                    {
                        ticket_task.Alarm1 = ((DateTime)reader[17]);
                    }
                    if (!DBNull.Value.Equals(reader[18]))
                    {
                        ticket_task.Alarm1_Ack_TS = ((DateTime)reader[18]);
                    }
                    if (!DBNull.Value.Equals(reader[19]))
                    {
                        ticket_task.Alarm2_Enabled = ((bool)reader[19]);
                    }
                    if (!DBNull.Value.Equals(reader[20]))
                    {
                        ticket_task.Alarm2 = ((DateTime)reader[20]);
                    }
                    if (!DBNull.Value.Equals(reader[21]))
                    {
                        ticket_task.Alarm2_Ack_TS = ((DateTime)reader[21]);
                    }
                    if (!DBNull.Value.Equals(reader[22]))
                    {
                        ticket_task.Alarm3_Enabled = ((bool)reader[22]);
                    }
                    if (!DBNull.Value.Equals(reader[23]))
                    {
                        ticket_task.Alarm3 = ((DateTime)reader[23]);
                    }
                    if (!DBNull.Value.Equals(reader[24]))
                    {
                        ticket_task.Alarm3_Ack_TS = ((DateTime)reader[24]);
                    }
                    if (!DBNull.Value.Equals(reader[25]))
                    {
                        ticket_task.Late_Alarm = ((bool)reader[25]);
                    }
                    active_tasks.Add(ticket_task);
                    task_count++;
                }
            }
            if (task_count == 0)
            {
                Task_Grid.Visibility = Visibility.Hidden;
            }
            else
            {
                Task_Grid.Visibility = Visibility.Visible;
            }
        }
コード例 #7
0
        public void Load_Site_Tickets()
        {
            int      current_tick = 0;
            DB_Users users        = new DB_Users();

            users.Get_List(0);

            // Delete the site tickets array before starting
            site_tickets.Clear();

            // Open the database and retrieve tickets for the current user or all of them if all is selected
            string connString = SQLConnString;

            // Query the tickets for this site for this user
            StringBuilder query = new StringBuilder("SELECT * FROM ");

            query.Append(tblTickets);
            query.Append(" WHERE Site_ID = '");
            query.Append(site_id.Site_ID);
            query.Append("'");
            // If select all is not enabled, only show this users tickets
            if ((bool)site_tickets_viewall.IsChecked == false)
            {
                query.Append(" AND Creator_ID = '");
                query.Append(cuser.User_ID);
                query.Append("'");
            }

            // Read all the tickets associated with this user
            using (SqlConnection sqlCon = new SqlConnection(connString))
            {
                sqlCon.Open();
                SqlCommand SqlCmd = new SqlCommand(query.ToString(), sqlCon);
                using SqlDataReader reader = SqlCmd.ExecuteReader();
                while (reader.Read())
                {
                    Site_Tickets site_ticket = new Site_Tickets();

                    site_ticket.Site_ID = ((long)reader[0]);
                    site_ticket.Get_Site_Name(site_ticket.Site_ID);
                    site_ticket.Ticket_ID       = ((long)reader[1]);
                    site_ticket.Creator_User_ID = ((long)reader[2]);
                    for (int i = 0; i < users.User_ID.Count; i++)
                    {
                        if (users.User_ID[i] == (int)site_ticket.Creator_User_ID)
                        {
                            site_ticket.Creator = users.User_Name[i];
                            break;
                        }
                    }
                    site_ticket.Created_On = ((DateTime)reader[3]);
                    if (!DBNull.Value.Equals(reader[4]))
                    {
                        site_ticket.Due_On = ((DateTime)reader[4]);
                    }
                    if (!DBNull.Value.Equals(reader[5]))
                    {
                        site_ticket.Brief_Desc = ((string)reader[5]);
                    }
                    if (!DBNull.Value.Equals(reader[6]))
                    {
                        site_ticket.Long_Desc = ((string)reader[6]);
                    }
                    if (!DBNull.Value.Equals(reader[7]))
                    {
                        site_ticket.Ticket_Status = ((int)reader[7]);
                    }
                    if (!DBNull.Value.Equals(reader[8]))
                    {
                        site_ticket.Completed_TS = ((DateTime)reader[8]);
                    }
                    if (!DBNull.Value.Equals(reader[9]))
                    {
                        site_ticket.Notes = ((string)reader[9]);
                    }
                    if (!DBNull.Value.Equals(reader[10]))
                    {
                        site_ticket.Total_Tasks = ((int)reader[10]);
                    }
                    if (!DBNull.Value.Equals(reader[11]))
                    {
                        site_ticket.Completed_Tasks = ((int)reader[11]);
                    }
                    if (!DBNull.Value.Equals(reader[12]))
                    {
                        site_ticket.Active_Tasks = ((int)reader[12]);
                    }
                    site_ticket.Changed = false;
                    site_tickets.Add(site_ticket);
                    current_tick++;
                }
            }
            if (current_tick == 0)
            {
                Site_Ticket_List.Visibility = Visibility.Hidden;
            }
            else
            {
                Site_Ticket_List.Visibility = Visibility.Visible;
            }
        }