Exemplo n.º 1
0
 protected void Submit2_Click(object sender, EventArgs e)
 {
     if (EmpID.Text == "" || QuarterID.Text == "")
     {
         Response.Write("<script>alert('Please enter all of the details.');</script>");
         ClearForm();
     }
     else if (CheckIfExists())
     {
         Response.Write("<script>alert('The employee is allocated to a quarter already or the quarter is already taken.');</script>");
         ClearForm();
     }
     else
     {
         AddNew();
         QuarterInfo.DataBind();
         ClearForm();
     }
 }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //This is to redirect the page if the user is not logged in
     if (string.IsNullOrEmpty((string)Session["role"]))
     {
         Response.Redirect("~/");
     }
     if (!IsPostBack)
     {
         SqlConnection connection = new SqlConnection(Strcon);
         connection.Open();
         SqlCommand Command  = new SqlCommand("SELECT employee.emp_id from employee LEFT JOIN allocatedquarter ON allocatedquarter.emp_id=employee.emp_id WHERE allocatedquarter.emp_id IS NULL;", connection);
         SqlCommand Command2 = new SqlCommand("SELECT quarterlist.quarter_id from quarterlist LEFT JOIN allocatedquarter ON allocatedquarter.quarter_id=quarterlist.quarter_id WHERE allocatedquarter.quarter_id IS NULL;", connection);
         EmpID.DataSource     = Command.ExecuteReader();
         QuarterID.DataSource = Command2.ExecuteReader();
         EmpID.DataBind();
         QuarterID.DataBind();
         QuarterID.Items.Insert(0, new ListItem("Select a quarter ID", ""));
         EmpID.Items.Insert(0, new ListItem("Select a employee ID", ""));
         QuarterInfo.DataBind();
         connection.Close();
     }
 }