protected void CreateUserWizard1_OnCreatedAdmin(object sender, EventArgs e)
        {
            var createAdminWizard = LV.FindControl("_CreateAdminWizard") as CreateUserWizard;

            if (createAdminWizard != null)
            {
                Roles.AddUserToRole(createAdminWizard.UserName, "Admin");
            }
        }
Exemple #2
0
    protected void AddActivityButton_OnClick(object sender, EventArgs e)
    {
        var calendar = LV.FindControl("GCalendar") as Calendar;

        Debug.Assert(calendar != null, nameof(calendar) + " != null");
        if (calendar.SelectedDate == DateTime.MinValue)
        {
            StatusMsg.Text = "No date added!";
            return;
        }
        var name = LV.FindControl("ANameTB") as TextBox;
        var desc = LV.FindControl("ADescTB") as TextBox;
        //StatusMsg.Text=calendar.SelectedDate.ToString();
        string gid = Server.UrlDecode(Request.Params["gid"]);

        try
        {
            SqlConnection con =
                new SqlConnection(
                    @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|Groups.mdf;Integrated Security=True;User Instance=False");
            con.Open();

            try
            {
                string cQuery = "INSERT INTO Activities" +
                                " (ActivityName, ActivityDate, ActivityDescription, GroupId)" +
                                " VALUES (@aname, @adate, @adesc, @gid)";
                SqlCommand cmd = new SqlCommand(cQuery, con);
                Debug.Assert(name != null, nameof(name) + " != null");
                cmd.Parameters.AddWithValue("aname", name.Text);
                cmd.Parameters.AddWithValue("adate", calendar.SelectedDate);
                Debug.Assert(desc != null, nameof(desc) + " != null");
                cmd.Parameters.AddWithValue("adesc", desc.Text);
                cmd.Parameters.AddWithValue("gid", gid);
                cmd.ExecuteNonQuery();
            }
            catch (Exception exception)
            {
                StatusMsg.Text = exception.Message;
            }
            finally
            {
                con.Close();
            }
        }
        catch (Exception exception)
        {
            StatusMsg.Text = exception.Message;
        }
        Response.Redirect("GroupPage.aspx?gid=" + Server.UrlEncode(gid));
    }
Exemple #3
0
    protected void btnUpdateImageSpecs_Click(object sender, EventArgs e)
    {
        Image_Physical_Specs ips = new Image_Physical_Specs();

        try
        {
            ips = JsonConvert.DeserializeObject <Image_Physical_Specs>(image.ClientSize);
        }
        catch
        { return; }

        int rowCounter = 0;

        foreach (GridViewRow row in gvHDs.Rows)
        {
            CheckBox box = row.FindControl("chkHDActive") as CheckBox;
            if (box.Checked)
            {
                ips.hd[rowCounter].active = "1";
            }
            else
            {
                ips.hd[rowCounter].active = "0";
            }

            GridView gvParts = (GridView)row.FindControl("gvParts");

            int partCounter = 0;
            foreach (GridViewRow partRow in gvParts.Rows)
            {
                CheckBox boxPart = partRow.FindControl("chkPartActive") as CheckBox;
                if (boxPart.Checked)
                {
                    ips.hd[rowCounter].partition[partCounter].active = "1";
                }
                else
                {
                    ips.hd[rowCounter].partition[partCounter].active = "0";
                }

                TextBox txtCustomSize = partRow.FindControl("txtCustomSize") as TextBox;
                if (!string.IsNullOrEmpty(txtCustomSize.Text))
                {
                    string customSize_BLK = (Convert.ToInt64(txtCustomSize.Text) * 1024 * 1024 / Convert.ToInt32(ips.hd[rowCounter].lbs)).ToString();
                    ips.hd[rowCounter].partition[partCounter].size_override = customSize_BLK;
                }


                GridView gvVG = (GridView)partRow.FindControl("gvVG");
                foreach (GridViewRow vg in gvVG.Rows)
                {
                    GridView gvLVS     = (GridView)vg.FindControl("gvLVS");
                    int      lvCounter = 0;
                    foreach (GridViewRow LV in gvLVS.Rows)
                    {
                        CheckBox boxLv = LV.FindControl("chkPartActive") as CheckBox;
                        if (boxLv.Checked)
                        {
                            ips.hd[rowCounter].partition[partCounter].vg.lv[lvCounter].active = "1";
                        }
                        else
                        {
                            ips.hd[rowCounter].partition[partCounter].vg.lv[lvCounter].active = "0";
                        }

                        TextBox txtCustomSizeLv = LV.FindControl("txtCustomSize") as TextBox;
                        if (!string.IsNullOrEmpty(txtCustomSizeLv.Text))
                        {
                            string customSize_BLK = (Convert.ToInt64(txtCustomSizeLv.Text) * 1024 * 1024 / Convert.ToInt32(ips.hd[rowCounter].lbs)).ToString();
                            ips.hd[rowCounter].partition[partCounter].vg.lv[lvCounter].size_override = customSize_BLK;
                        }
                        lvCounter++;
                    }
                }
                partCounter++;
            }
            rowCounter++;
        }

        if (image.UpdateSpecs(image.Name, JsonConvert.SerializeObject(ips)))
        {
            Master.Msgbox("Successfully Updated Image Specs");
        }
        else
        {
            Master.Msgbox("Could Not Update Image Specs");
        }
    }
Exemple #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int gid2 = 0;

        try
        {
            gid2 = int.Parse(Server.UrlDecode(Request.Params["gid"]) ?? throw new InvalidOperationException());
        }
        catch (Exception exception)
        {
            Response.Redirect("~/UserPages/MyGroups.aspx");
            Console.WriteLine(exception.Message + "\n");
        }
        if (Request.Params["gid"] != null)
        {
            string gid   = Server.UrlDecode(Request.Params["gid"]);
            int    catId = 0;
            bool   isMod = false;
            bool   isMem = false;
            bool   mem   = false;

            try
            {
                SqlConnection con =
                    new SqlConnection(
                        @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|Groups.mdf;Integrated Security=True;User Instance=False");
                con.Open();

                try
                {
                    // luam date despre grup din baza de date
                    string groupQuery = "SELECT [GroupName], [GroupDescription], [CategoryId] " +
                                        "FROM [Groups] WHERE GroupId = @gid";
                    SqlCommand cmd = new SqlCommand(groupQuery, con);
                    cmd.Parameters.AddWithValue("gid", gid);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        TitleLiteral.Text = reader["GroupName"].ToString();
                        GNameLiteral.Text = reader["GroupName"].ToString();
                        GDescLiteral.Text = reader["GroupDescription"].ToString();
                        catId             = int.Parse(reader["CategoryId"].ToString());
                    }
                    reader.Close();
                    // afisam categoria
                    string     cQuery = "SELECT [CategoryName] FROM [Categories] WHERE CategoryId = @catid";
                    SqlCommand cmd2   = new SqlCommand(cQuery, con);
                    cmd2.Parameters.AddWithValue("catid", catId);
                    reader = cmd2.ExecuteReader();
                    while (reader.Read())
                    {
                        CategoryLiteral.Text = reader["CategoryName"].ToString();
                    }
                    reader.Close();

                    // acum vedem daca userul este membru al grupului
                    string glist =
                        "SELECT [IsModerator], [IsMember] FROM GroupsLists WHERE UserName = @uname AND GroupId = @gid";
                    SqlCommand cmd3 = new SqlCommand(glist, con);
                    cmd3.Parameters.AddWithValue("uname", User.Identity.Name);
                    cmd3.Parameters.AddWithValue("gid", gid);
                    reader = cmd3.ExecuteReader();

                    while (reader.Read())
                    {
                        //var modCB = LV.FindControl("ModCB") as CheckBox;
                        //var memberCB = LV.FindControl("MemberCB") as CheckBox;
                        //modCB.Checked =
                        mem   = true;
                        isMod = bool.Parse(reader["IsModerator"].ToString());
                        //memberCB.Checked =
                        isMem = bool.Parse(reader["IsMember"].ToString());
                    }
                    reader.Close();

                    if (isMem)
                    {
                        hidIsMem.Value = "true";
                    }
                    // else { hidIsMem.Value = "false"; }
                    if (isMod)
                    {
                        hidIsMod.Value = "true";
                    }
                    // else { hidIsMod.Value = "false"; }
                    if (mem)
                    {
                        hidMem.Value = "true";
                    }


                    //LoadPosts(con, gid);
                    // apoi afisam postarile, fisierele, activitatile
                    var calendar = LV.FindControl("GCalendar") as Calendar;
                    Debug.Assert(calendar != null, nameof(calendar) + " != null");
                    string aQuery = "SELECT ActivityDate" +
                                    " FROM Activities" +
                                    " WHERE GroupId = @gid";
                    SqlCommand acmd = new SqlCommand(aQuery, con);
                    acmd.Parameters.AddWithValue("gid", gid);
                    reader = acmd.ExecuteReader();
                    while (reader.Read())
                    {
                        calendar.SelectedDates.Add(DateTime.Parse(reader["ActivityDate"].ToString()));
                    }
                    reader.Close();
                }
                catch (Exception exception)
                {
                    StatusMsg.Text += "\n" + exception.Message;
                }
                finally
                {
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                StatusMsg.Text += "\n" + ex.Message;
            }

            HLMembers.NavigateUrl = "~/GroupMembers.aspx?gid=" + Server.UrlEncode(gid2.ToString());
        }
    }