Пример #1
0
        private void Bug_Load(object sender, EventArgs e)
        {
            BugReport vb = new BugReport();
            DataTable dt = vb.Select_bug();

            dataGridView.DataSource = dt;
            string type = LoginForm.usertype;

            if (type == "Admin")
            {
                label_header.Text = "Manage bug";
            }
            else
            {
                label_header.Text = "Enter a new bug";
            }
        }
Пример #2
0
        private void textBox_search_TextChanged(object sender, EventArgs e)
        {
            //get keyword from textbox
            string    keyword = textBox_search.Text;
            BugReport vb1     = new BugReport();

            if (keyword != null)
            {
                DataTable dt = vb1.Search_bug(keyword);
                dataGridView.DataSource = dt;
            }
            else
            {
                //show all user from database
                DataTable dt = vb1.Select_bug();
                dataGridView.DataSource = dt;
            }
        }
Пример #3
0
        private void button_delete_Click(object sender, EventArgs e)
        {
            //Checking if the user is admin or user or debugger
            string type = LoginForm.usertype;

            if (type == "Admin")
            {
                //Database connection
                MySqlConnection conn = new MySqlConnection("server = localhost; user id = root; database = bugbase");

                MySqlCommand sda = new MySqlCommand("DELETE FROM bugreport WHERE id='" + this.textBox_bugid.Text + "'", conn);
                conn.Open();

                //Step 6: Execute cmd
                int rows = sda.ExecuteNonQuery();
                //if sda is success rows value is greater than 0
                if (rows > 0)
                {
                    MessageBox.Show("Bug Deleted Successfully. Thank You.");
                    //Refresh Data Grid View
                    BugReport vb = new BugReport();
                    DataTable dt = vb.Select_bug();
                    dataGridView.DataSource = dt;
                    //Clear all the Input fields
                    textBox_bugid.Clear();
                    comboBox_project.Text = "";
                    textBox_bugtitle.Clear();
                    textBox_bugissue.Clear();
                    reportDate.Text      = "";
                    lbl_img_path.Text    = "path";
                    combo_bugStatus.Text = "";
                }
                else
                {
                    //Delete Failed Message
                    MessageBox.Show("Failed to delte bug. Please Try Again.");
                }
            }
            else
            {
                //Display message
                MessageBox.Show("Sorry! You are not allowed to remove any data.");
            }
        }
Пример #4
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            MySqlConnection conn  = new MySqlConnection("server = localhost; user id = root; database = bugbase");
            int             BugID = 0;

            if (textBox_bugid.Text.Trim() != "")
            {
                BugID = int.Parse(textBox_bugid.Text.Trim());
            }
            string ProjectTitle   = comboBox_project.Text.ToString();
            string BugTitle       = textBox_bugtitle.Text.Trim();
            string BugDescription = textBox_bugissue.Text.Trim();
            string ReportDate     = reportDate.Text.Trim();
            string ImagePath      = lbl_img_path.Text.Trim();
            string status         = combo_bugStatus.Text.ToString();

            //Getting loggedin user in added by field
            string loggeduser = LoginForm.uname;
            string reportedby = loggeduser;

            ReportDate = DateTime.Now.ToString("yyyy-MM-dd");


            try
            {
                //Database connection
                MySqlCommand sda = new MySqlCommand("INSERT INTO bugreport (project, bugtitle, bugissue, reportdate,status,image,reportedby) VALUES ('" + this.comboBox_project.Text + "','" + this.textBox_bugtitle.Text + "','" + this.textBox_bugissue.Text + "','" + this.reportDate.Text + "','" + this.combo_bugStatus.Text + "','" + this.lbl_img_path.Text + "',@reportedby)", conn);
                sda.Parameters.AddWithValue("@reportedby", reportedby);
                conn.Open();
                int rows = sda.ExecuteNonQuery();

                if (rows > 0)
                {
                    MessageBox.Show("Bug added to database. click ok to continue");
                    //Refresh Data Grid View
                    BugReport vb = new BugReport();
                    DataTable dt = vb.Select_bug();
                    dataGridView.DataSource = dt;
                    //Clear all the Input fields
                    textBox_bugid.Clear();
                    comboBox_project.Text = "";
                    textBox_bugtitle.Clear();
                    textBox_bugissue.Clear();
                    reportDate.Text      = "";
                    lbl_img_path.Text    = "path";
                    combo_bugStatus.Text = "";
                }
                else
                {
                    MessageBox.Show("Bug failed to database. click ok to continue");
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            finally
            {
                //Step :CLose Connection
                conn.Close();
            }
        }
Пример #5
0
        private void button_update_Click(object sender, EventArgs e)
        {
            MySqlConnection conn  = new MySqlConnection("server = localhost; user id = root; database = bugbase");
            int             BugID = 0;

            if (textBox_bugid.Text.Trim() != "")
            {
                BugID = int.Parse(textBox_bugid.Text.Trim());
            }
            string ProjectTitle   = comboBox_project.Text.ToString();
            string BugTitle       = textBox_bugtitle.Text.Trim();
            string BugDescription = textBox_bugissue.Text.Trim();
            string ReportDate     = reportDate.Text.Trim();
            string ImagePath      = lbl_img_path.Text.Trim();
            string status         = combo_bugStatus.Text.ToString();
            string loggedusertype = LoginForm.usertype;

            string reportedby = loggedusertype;

            ReportDate = DateTime.Now.ToString("yyyy-MM-dd");


            try
            {
                //Database connection
                MySqlCommand sda = new MySqlCommand("update bugreport set project='" + this.comboBox_project.Text + "',bugtitle='" + this.textBox_bugtitle.Text + "',bugissue='" + this.textBox_bugissue.Text + "',reportdate='" + this.reportDate.Text + "',status='" + this.combo_bugStatus.Text + "',image='" + this.lbl_img_path.Text + "' where bugreport.id='" + this.textBox_bugid.Text + "'", conn);
                conn.Open();

                int rows = sda.ExecuteNonQuery();

                if (rows > 0)
                {
                    MessageBox.Show("Bug updated. click ok to continue");
                    //Refresh Data Grid View
                    BugReport vb = new BugReport();
                    DataTable dt = vb.Select_bug();
                    dataGridView.DataSource = dt;
                    //Clearing the fields
                    textBox_bugid.Clear();
                    comboBox_project.Text = "";
                    textBox_bugtitle.Clear();
                    textBox_bugissue.Clear();
                    reportDate.Text      = "";
                    lbl_img_path.Text    = "path";
                    combo_bugStatus.Text = "";
                }
                else
                {
                    MessageBox.Show("Bug failed to update. click ok to continue");
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            finally
            {
                //Close Connection
                conn.Close();
            }
        }