/// <summary> /// Method to add a note to a project record. /// If the textbox control tb_NewProjectNote is not empty the entered value is inserted into a table within /// the SQL Server database. /// Assigns the contents of tb_NewProjectNote to a variable (newProjectNote), creates a new Project class /// object and passes the parameter pNumber and variable newProjectNote to a method it contains (insertProjectNote). /// Refreshes class DataSet (ds_Project) and datagrid view before clearing the contents of the text box (tb_NewProjectNote). /// </summary> /// <param name="pNumber"></param> private void addKristalNote(int kristalRef) { string newKristalNote; if (tb_NewKristalNote.Text != "") { try { //place the new note text into the string variable (newProjectNote) newKristalNote = tb_NewKristalNote.Text; //instantiate new Project type object that contains methods to update db Kristal kristal = new Kristal(); //add the note to the SQL table kristal.insertKristalNote(kristalRef, newKristalNote); //refresh the DataSet (ds_Project) ds_Kristal = kristal.getKristalDataSet(); //repopulate the DataGridView (dgv_pNotes) setKristalNotes(); //clear the textbox control tb_NewKristalNote.Clear(); } catch (Exception ex) { MessageBox.Show("Failed to add new note" + Environment.NewLine + ex); throw; } } }
public void setKristal(mdl_Kristal mdl_Kristal) { try { current_Kristal = mdl_Kristal; Kristal kristal = new Kristal(); ds_Kristal = kristal.getKristalDataSet(); lbl_KristalRefValue.Text = current_Kristal.KristalRef.ToString(); DataView GrantStages = new DataView(ds_Kristal.Tables["tlkGrantStage"]); GrantStages.RowFilter = "[ValidTo] is null"; cb_GrantStage.DataSource = GrantStages; cb_GrantStage.ValueMember = "GrantStageID"; cb_GrantStage.DisplayMember = "GrantStageDescription"; cb_GrantStage.SelectedValue = current_Kristal.GrantStageID; tb_KristalName.Text = current_Kristal.KristalName; } catch (Exception ex) { MessageBox.Show("Method setKristalEdit of class frm_ProjectKristalEdit has failed" + Environment.NewLine + Environment.NewLine + ex.Message); } }
private void fillKristalDataSet() { Kristal kristal = new Kristal(); ds_kristal = kristal.getKristalDataSet(); }