-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnnounce.aspx.cs
53 lines (43 loc) · 1.66 KB
/
Announce.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void close_Click(object sender, EventArgs e)
{
Response.Redirect("hr_employee", true);
}
protected void btn_post_Click(object sender, EventArgs e)
{
string connStr = ConfigurationManager.ConnectionStrings["iWorkDBConn"].ToString();
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("postAnnouncements", conn);
cmd.CommandType = CommandType.StoredProcedure;
string username = (string)Session["username"];
cmd.Parameters.AddWithValue("@hr_username", username);
if(txtbox_title.Text.Equals("") || txtbox_type.Text.Equals("") || txt_desc.Text.Equals(""))
Response.Write(@"<script language='javascript'>alert('" + "Do not leave empty fields, cyka!" + "');</script>");
else
{
cmd.Parameters.AddWithValue("@description", txt_desc.Text);
cmd.Parameters.AddWithValue("@type", txtbox_type.Text);
cmd.Parameters.AddWithValue("@title", txtbox_title.Text);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Response.Write(@"<script language='javascript'>alert('" + "Announcement Posted!" + "');</script>");
txtbox_title.Text = "";
txtbox_type.Text = "";
txt_desc.Text = "";
}
}
}