コード例 #1
0
        protected void Confirm_Click(object sender, EventArgs e)
        {
            var    manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
            string vars    = ((Button)sender).CommandArgument;

            string[] splitVars = vars.Split(',');

            if (((Button)sender).CommandName.Equals("Facilitator"))
            {
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
                conn.Open();
                string insert = "BEGIN IF NOT EXISTS (select * from Facilitators as F where F.Id = @Email and F.FirstName = @FacilitatorFirst and F.LastName = @FacilitatorLast)" +
                                " BEGIN insert into Facilitators(Id,FirstName, LastName) values (@Email,@FacilitatorFirst, @FacilitatorLast) END END";
                SqlCommand cmd = new SqlCommand(insert, conn);
                cmd.Parameters.AddWithValue("@Email", splitVars[0]);
                cmd.Parameters.AddWithValue("@FacilitatorFirst", splitVars[1]);
                cmd.Parameters.AddWithValue("@FacilitatorLast", splitVars[2]);
                cmd.ExecuteNonQuery();

                //Remove if one of the fields is empty
                string     remove = "delete from Facilitators where ID = '' or FirstName = '' or LastName = ''";
                SqlCommand rm     = new SqlCommand(remove, conn);
                rm.ExecuteNonQuery();
                conn.Close();
                removeOnConfirm(Int32.Parse(splitVars[3]), ((Button)sender).CommandName);
                ConfirmPopupExtender.Hide();
                manager.SendEmail(splitVars[0], "Facilitator Request", "Your request to have " + splitVars[1] + " " + splitVars[2] + " as a facilitator has been ACCEPTED!");
                Response.Redirect(Request.RawUrl);
                //ErrorMessage.Text = "Added " + splitVars[1] + " " + splitVars[2] + " as a Facilitator to " + splitVars[0];
            }
            //add query so it updates the confirmed column to 1 and subtract hours they
            //are missing from monthly and yearly
            if (((Button)sender).CommandName.Equals("Absence"))
            {
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
                conn.Open();
                string     update = "UPDATE Absence SET Confirmed = @confirm Where Id = @Id";
                SqlCommand cmd    = new SqlCommand(update, conn);
                cmd.Parameters.AddWithValue("@confirm", 1);
                cmd.Parameters.AddWithValue("@Id", Int32.Parse(splitVars[3]));
                cmd.ExecuteNonQuery();
                conn.Close();
                AbsencePopupExtender.Hide();
                manager.SendEmail(splitVars[0], "Absence Request", "Your request to have a facilitation absence from " + splitVars[1] + " to " + splitVars[2] + " has been ACCEPTED!");
                Response.Redirect(Request.RawUrl);
            }
        }
コード例 #2
0
 protected void cancelAbsenceReq(object sender, System.EventArgs e)
 {
     AbsencePopupExtender.Hide();
 }