protected void btnSubmit_Click(object sender, EventArgs e)
{
connectionString = ConfigurationManager.ConnectionStrings["FacilityCS"].ConnectionString;
conn = new SqlConnection(connectionString);
string sql = "UPDATE Staff SET StaffId=@staffId, Password=@password, StaffName=@staffName,";
sql+=" Email=@email, PhoneNo=@phoneNo, Title=@title, Role=@role";
try
{
cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddWithValue("@staffId", tbStaffId.Text);
cmd.Parameters.AddWithValue("@password", tbPassword.Text);
cmd.Parameters.AddWithValue("@staffName", tbStaffName.Text);
cmd.Parameters.AddWithValue("@email", tbEmail.Text);
cmd.Parameters.AddWithValue("@phoneNo", tbPhoneNo.Text);
cmd.Parameters.AddWithValue("@title", Convert.ToInt32(ddlTitle.SelectedValue));
cmd.Parameters.AddWithValue("@role", Convert.ToInt32(rbRole.SelectedValue));
conn.Open();
int row = cmd.ExecuteNonQuery();
if(row>0)
{
lblOutput.Text = "Record Updated successfully";
}
}
catch(Exception ex)
{
lblOutput.Text = "Error Message: " + ex.Message;
}
finally
{
if (conn != null)
conn.Close();
}
}