//for searching private void txt_searchbug_TextChanged(object sender, EventArgs e) { //get keyword from textbox string keyword = txt_searchbug.Text; BugReport vb1 = new BugReport(); //check if keywords have value or not if (keyword != null) { //show user based based on keywords DataTable dt = vb1.Search_bug(keyword); dgv_bug.DataSource = dt; } else { //show all user from database DataTable dt = vb1.Select_bug(); dgv_bug.DataSource = dt; } }
private void btn_updatebug_Click(object sender, EventArgs e) { int BugID = 0; if (txtBox_bugID.Text.Trim() != "") { BugID = int.Parse(txtBox_bugID.Text.Trim()); } string ProjectTitle = comboBoxProject.Text.ToString(); string BugTitle = textBox_bugtitle.Text.Trim(); string BugDescription = textBox_bugdescription.Text.Trim(); string ReportDate = dateTimePicker_reportdate.Text.Trim(); string ImagePath = lbl_img_path.Text.Trim(); string status = cmbBox_status.Text.ToString(); // int addedby = ; ReportDate = DateTime.Now.ToString("yyyy-MM-dd"); //connecting to the database MySqlConnection conn = new MySqlConnection("server = localhost; user id = root; database = bugtracker"); try { MySqlCommand sda = new MySqlCommand("update bug set ProjectTitle='" + this.comboBoxProject.Text + "',BugTitle='" + this.textBox_bugtitle.Text + "',BugDescription='" + this.textBox_bugdescription.Text + "',ReportDate='" + this.dateTimePicker_reportdate.Text + "',image='" + this.lbl_img_path.Text + "',status='" + this.cmbBox_status.Text + "' where bug.id='" + this.txtBox_bugID.Text + "'", conn); //Open Connection conn.Open(); int rows = sda.ExecuteNonQuery(); //if Inserted rows is greater is greater than 0 //Else set isSuccess to false, Save Failed if (rows > 0) { MessageBox.Show("Bug updated. click ok to continue"); //Refresh Data Grid View BugReport vb = new BugReport(); DataTable dt = vb.Select_bug(); dgv_bug.DataSource = dt; //Clear all the Input fields txtBox_bugID.Clear(); comboBoxProject.Text = ""; textBox_bugtitle.Clear(); textBox_bugdescription.Clear(); dateTimePicker_reportdate.Text = ""; lbl_img_path.Text = "[image path]"; } 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(); } }
private void btn_viewbug_Click(object sender, EventArgs e) { user.BugReport bug = new user.BugReport(); bug.Show(); this.Hide(); }