private void UpdateBug_Load_1(object sender, EventArgs e) { BugDAO bugDAO = new BugDAO(); bug = bugDAO.GetById(Program.bugId); this.StartPosition = FormStartPosition.CenterScreen; //this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; if (disableButtons) { textBox2.Enabled = false; textBox3.Enabled = false; textBox4.Enabled = false; textBox5.Enabled = false; button2.Hide(); button3.Hide(); btnUpdate.Hide(); button5.Show(); } else { button5.Show(); } //binding value to related labels and textbox label1.Text = bug.ProjectName; textBox2.Text = bug.ClassName; textBox3.Text = bug.MethodName; textBox4.Text = bug.StartLine.ToString(); textBox5.Text = bug.EndLine.ToString(); programminLanguage = bug.Codes.ProgrammingLanguage; currentImageName = bug.Images.ImageName; codeFileName = bug.Codes.CodeFileName; //assiging related table's id bugId = bug.BugId; codeId = bug.Codes.CodeId; imageId = bug.Images.ImageId; linkLabel1.Text = bug.SourceControl.Link; /* * Open the file to read from. * reading text from code file */ string path = bug.Codes.CodeFilePath + "/" + bug.Codes.CodeFileName + ".txt"; using (StreamReader sr = File.OpenText(path)) { string s = ""; while ((s = sr.ReadLine()) != null) { fastColoredTextBox1.Text = fastColoredTextBox1.Text + Environment.NewLine + s; } } //assigning programming language for text box string programmingLanguage = bug.Codes.ProgrammingLanguage; if (programmingLanguage == "CSharp") { fastColoredTextBox1.Language = FastColoredTextBoxNS.Language.CSharp; } else if (programmingLanguage == "HTML") { fastColoredTextBox1.Language = FastColoredTextBoxNS.Language.HTML; } else if (programmingLanguage == "JavaScript") { fastColoredTextBox1.Language = FastColoredTextBoxNS.Language.JS; } else if (programmingLanguage == "Lua") { fastColoredTextBox1.Language = FastColoredTextBoxNS.Language.Lua; } else if (programmingLanguage == "PHP") { fastColoredTextBox1.Language = FastColoredTextBoxNS.Language.PHP; } else if (programmingLanguage == "SQL") { fastColoredTextBox1.Language = FastColoredTextBoxNS.Language.SQL; } else if (programmingLanguage == "VB") { fastColoredTextBox1.Language = FastColoredTextBoxNS.Language.VB; } else if (programmingLanguage == "XML") { fastColoredTextBox1.Language = FastColoredTextBoxNS.Language.XML; } if (bug.Images.ImageName != "") { pictureBox1.Image = new Bitmap(Path.Combine(bug.Images.ImagePath + "/", bug.Images.ImageName)); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; } }
private void btnUpdate_Click(object sender, EventArgs e) { //bug Bug_Tracker.Model.Bug bug = new Bug_Tracker.Model.Bug { BugId = bugId, ProjectName = label1.Text, ClassName = textBox2.Text, MethodName = textBox3.Text, StartLine = Convert.ToInt16(textBox4.Text), EndLine = Convert.ToInt16(textBox5.Text), ProgrammerId = Login.userId, Status = "0" }; try { BugDAO bugDao = new BugDAO(); bugDao.Update(bug); } catch (Exception ex) { Console.WriteLine(ex.Message); } //image if (!string.IsNullOrEmpty(ImageName)) { string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\code_image\"; Bug_Tracker.Model.Image image = new Bug_Tracker.Model.Image { ImageId = imageId, ImagePath = "code_image", ImageName = ImageName, BugId = bug.BugId }; try { ImageDAO codeDao = new ImageDAO(); codeDao.Update(image); File.Delete("code_image/" + currentImageName); File.Copy(imageName, appPath + ImageName); } catch (Exception ex) { Console.WriteLine(ex.Message); } } string c = fastColoredTextBox1.Text; try { string path = @"code/" + codeFileName + ".txt"; using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(c); } } catch (Exception ex) { Console.WriteLine(ex.Message); } MessageBox.Show("Updated"); }
private void button1_Click(object sender, EventArgs e) { //timro tyo name har u milena validation hatau baru.. k milena ra? maile paile ta sap ramrai name rakhya ho if (string.IsNullOrEmpty(comboBox1.SelectedItem.ToString()) || string.IsNullOrEmpty(textBox2.Text) || string.IsNullOrEmpty(textBox3.Text) || string.IsNullOrEmpty(textBox4.Text) || string.IsNullOrEmpty(textBox5.Text) || string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox6.Text) || string.IsNullOrEmpty(textBox7.Text)) { MessageBox.Show("You must add all project information"); } else if (string.IsNullOrEmpty(fastColoredTextBox1.Text)) { MessageBox.Show("Code field cann't be null"); } else { //bug Bug_Tracker.Model.Bug bug = new Bug_Tracker.Model.Bug { ProjectName = comboBox1.SelectedItem.ToString(), ClassName = textBox2.Text, MethodName = textBox3.Text, StartLine = Convert.ToInt16(textBox4.Text), EndLine = Convert.ToInt16(textBox5.Text), ProgrammerId = Login.userId, Status = "0" }; try { BugDAO bugDao = new BugDAO(); bugDao.Insert(bug); inserted = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } //image if (!string.IsNullOrEmpty(imageName)) { string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\code_image\"; Bug_Tracker.Model.Image image = new Bug_Tracker.Model.Image { ImagePath = "code_image", ImageName = ImageName, BugId = bug.BugId }; try { ImageDAO codeDao = new ImageDAO(); codeDao.Insert(image); File.Copy(imageName, appPath + ImageName); inserted1 = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } } ////code string c = fastColoredTextBox1.Text; string codeFileName = DateTime.Now.Second.ToString(); Code code = new Code { CodeFilePath = "code", CodeFileName = codeFileName, ProgrammingLanguage = programminLanguage, BugId = bug.BugId }; try { CodeDAO codeDao = new CodeDAO(); codeDao.Insert(code); string path = "code/" + codeFileName + ".txt"; if (!File.Exists(path)) { // Create a file to write to. using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(c); } } inserted2 = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } ////Link SourceControl sourceControl = new SourceControl { Link = textBox1.Text, StartLine = Convert.ToInt32(textBox6.Text), EndLine = Convert.ToInt32(textBox7.Text), BugId = bug.BugId }; SourceControlDAO sourceControlDAO = new SourceControlDAO(); try { sourceControlDAO.Insert(sourceControl); inserted3 = true; } catch (Exception ex) { Console.WriteLine(ex.Message); } if (inserted && inserted1 && inserted2) { MessageBox.Show("Added"); } else { MessageBox.Show("Unable to add"); } } }