private void btnRefresh_Click(object sender, EventArgs e) { LoginDetails k = new LoginDetails(); Connection g = new Connection(); using (SqlConnection con = new SqlConnection(g.connectionClass())) { using (SqlCommand cmd = new SqlCommand("SELECT Report_Title, Report_DateTime, Report_Recipient, Report_Content FROM Synch_Report WHERE Report_UserAccount=" + k.GetUserID(), con)) { cmd.CommandType = CommandType.Text; using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { using (DataTable dt = new DataTable()) { sda.Fill(dt); gridview.DataSource = dt; gridview.AutoGenerateColumns = false; gridview.Columns["Report_Title"].HeaderText = "Title"; gridview.Columns["Report_DateTime"].HeaderText = "Date Time Created"; gridview.Columns["Report_DateTime"].HeaderText = "Recipient"; gridview.Columns["Report_Content"].HeaderText = "Content"; } } } } }
private void SendReportNew() { Connection g = new Connection(); LoginDetails l = new LoginDetails(); using (SqlConnection connection = new SqlConnection(g.connectionClass())) { connection.Open(); SqlCommand addSite = new SqlCommand("INSERT INTO Synch_Report (Report_UserAccount ,Report_Title, Report_DateTime, Report_Recipient, Report_Content)" + "VALUES (@report_account,@report_title, @report_date, @report_recipient, @report_content)", connection); addSite.Parameters.AddWithValue("@report_account", l.GetUserID()); addSite.Parameters.AddWithValue("@report_title", textBox1.Text); addSite.Parameters.AddWithValue("@report_date", DateTime.Now.ToString()); addSite.Parameters.AddWithValue("@report_recipient", comboBox1.SelectedValue.ToString()); addSite.Parameters.AddWithValue("@report_content", richTextBox1.Text); addSite.ExecuteNonQuery(); MessageBox.Show("Your Report has been submitted to your Manager."); txtManager.Text = ""; textBox1.Text = ""; richTextBox1.Text = ""; connection.Close(); } }
private void MainForm_Load(object sender, EventArgs e) { this.synch_AccountsTableAdapter.Fill(this.synchDataDataSet.Synch_Accounts); LoginDetails k = new LoginDetails(); Inside l = new Inside(); label4.Text = "Welcome," + l.GetMyName(k.GetUserID()) + "!"; timer1.Enabled = true; timer1.Interval = 1000; Connection g = new Connection(); using (SqlConnection con = new SqlConnection(g.connectionClass())) { using (SqlCommand cmd = new SqlCommand("SELECT Report_Title, Report_DateTime, Report_Recipient, Report_Content FROM Synch_Report WHERE Report_UserAccount=" + k.GetUserID(), con)) { cmd.CommandType = CommandType.Text; using (SqlDataAdapter sda = new SqlDataAdapter(cmd)) { using (DataTable dt = new DataTable()) { sda.Fill(dt); gridview.DataSource = dt; gridview.AutoGenerateColumns = false; gridview.Columns["Report_Title"].HeaderText = "Title"; gridview.Columns["Report_DateTime"].HeaderText = "Date Time Created"; gridview.Columns["Report_DateTime"].HeaderText = "Recipient"; gridview.Columns["Report_Content"].HeaderText = "Content"; } } } } }
private void SendReport_Load(object sender, EventArgs e) { Connection g = new Connection(); SqlDataReader dr; SqlConnection con = new SqlConnection(g.connectionClass()); SqlCommand cmd = new SqlCommand("SELECT SynchEmp_No, SynchEmp_FirstName, SynchEmp_LastName FROM Synch_EmpInfo WHERE SynchEmp_Level = 'Manager'", con); con.Open(); cmd.CommandType = CommandType.Text; dr = cmd.ExecuteReader(); var items = new List<string>(); while(dr.Read()) { items.Add(dr["SynchEmp_No"].ToString()); } comboBox1.DataSource = items; con.Close(); }