private void AddUser()
        {
            if (!String.IsNullOrWhiteSpace(userNameTextBox.Text) &&
                !String.IsNullOrWhiteSpace(passwordTextBox.Text) &&
                !String.IsNullOrWhiteSpace(emailTextBox.Text))
            {
                User newUser = new User {
                    Username = userNameTextBox.Text,
                    Password = passwordTextBox.Text,
                    Email    = emailTextBox.Text,
                    RoleID   = roleComboBox.SelectedIndex + 1
                };

                codeHogEntities.Users.Add(newUser);

                try {
                    codeHogEntities.SaveChanges();
                }
                catch (DbUpdateException ex) {
                    MessageBox.Show(ex.Message);
                }

                BindUserList();
            }
            else
            {
                MessageBox.Show("ERROR: One or more of the Textfeilds are Empty");
            }
        }
 //saves all changes
 private void ConfirmChangesButton_Click(object sender, EventArgs e)
 {
     codeHogEntities.SaveChanges();
     UpdateDataGrid();
     MessageBox.Show("Your changes have been save!");
     confirmChangesButton.Enabled = false;
 }
示例#3
0
        //Adds note
        private void Button1_Click(object sender, EventArgs e)
        {
            newNote = noteTextBox.Text; //grabs the input text from the text box, and prepares it for storage in the DB

            //get user ID #
            foreach (var ticket in codeHogEntities.Users) //find the current user in the DB
            {
                if (ticket.Username == userN)             //get the user's #
                {
                    userIDNum = ticket.UserID;
                }
            }

            //update the ticket entry with the new note text and username
            Note newNoteEntry = new Note();

            newNoteEntry.TicketID = ticketNumber;
            newNoteEntry.UserID   = userIDNum;
            newNoteEntry.Note1    = newNote;

            codeHogEntities.Notes.Add(newNoteEntry);
            codeHogEntities.SaveChanges();

            //close the form
            this.Close();
        }
示例#4
0
        private void DeleteTicketButton_Click(object sender, EventArgs e)
        {
            int TicketId = Convert.ToInt32(ticketIDLabel.Text);

            foreach (var ticket in codeHogEntities.Tickets)
            {
                if (ticket.TicketID == TicketId)
                {
                    codeHogEntities.Tickets.Remove(ticket);
                    codeHogEntities.SaveChanges();
                    Close();
                }
            }
        }
示例#5
0
        //save
        private void ChangeButton_Click(object sender, EventArgs e)
        {
            //update the ticket entry with the new priority
            foreach (var ticket in codeHogEntities.Tickets) //find the current ticket in the DB
            {
                if (ticket.TicketID == ticketNumber)        //if the ticket in the DB is the ticket we are looking for
                {
                    //Update priority on the current ticket
                    ticket.TicketPriority = chosenPriority;
                }
            }

            //Save changes to DB
            codeHogEntities.SaveChanges(); //TODO FIX

            //close the form
            this.Close();
        }
示例#6
0
        private void ButtonNewTicket_Click(object sender, EventArgs e)
        {
            //Prioerity Checking
            int Pri = -1;

            if (radioPri1.Checked)
            {
                Pri = 1;
            }
            else if (radioPri2.Checked)
            {
                Pri = 2;
            }
            else if (radioPri3.Checked)
            {
                Pri = 3;
            }
            else if (radioPri4.Checked)
            {
                Pri = 4;
            }
            else if (radioPri5.Checked)
            {
                Pri = 5;
            }

            int Status = -1;

            if (RadioStat1.Checked)
            {
                Status = 1;
            }
            else if (RadioStat2.Checked)
            {
                Status = 2;
            }
            else if (RadioStat3.Checked)
            {
                Status = 3;
            }

            //Checking if all the required fileds are tehere
            if (TextName.TextLength == 0 || TextDesc.TextLength == 0 || Pri == -1)
            {
                MessageBox.Show("One of the required fields is missing");
            }
            else
            {
                //Reporter should be the person who logs in UserId. Just putting a placeholder here for future referecne.
                int Reporter = CurrUser.Id;

                var NewTicket = new Ticket()
                {
                    TicketArchiveStatus = false,
                    TicketStatus        = Status,
                    TicketReporter      = Reporter,

                    TicketDescription = TextDesc.Text,
                    TicketName        = TextName.Text,
                    TicketPriority    = Pri,
                };
                Database.Tickets.Add(NewTicket);
                Database.SaveChanges();
                // Dependcies checking

                //Gettingt he piramary ticket ID
                var    query   = Database.Tickets.Where(s => s.TicketID == NewTicket.TicketID);
                Ticket Ticketp = query.FirstOrDefault <Ticket>();


                //Create a new dependecny, and add it to database
                foreach (DataGridViewRow temp in DataGridView1.SelectedRows)
                {
                    int ticketidrow = Int32.Parse(temp.Cells[0].Value.ToString());
                    query = Database.Tickets.Where(s => s.TicketID == ticketidrow);
                    Dependency dependency = new Dependency()
                    {
                        DependentTicketID = query.FirstOrDefault <Ticket>().TicketID,
                        TicketID          = Ticketp.TicketID
                    };
                    Database.Dependencies.Add(dependency);
                    Database.SaveChanges();
                }
                //query = Database.Dependencies.Where(s => s.DependentTicketID == );
                //NewTicket.Dependencies=
                UpdateDataGrid();

                // This is the default values of a newly created ticket.
                //var wow=Database.Database.ExecuteSqlCommand("FROM * SELECT *");
            }
        }