protected void DropButton_Command(object sender, CommandEventArgs e)
 {
     using (var db = new DataBase.DataClasses1DataContext(WebConfigurationManager.ConnectionStrings["dziennikucznia_studentlive_plConnectionString"].ConnectionString))
     {
         var student = (from s in db.aspnet_Memberships where s.UserId == new Guid(e.CommandArgument.ToString()) select s).FirstOrDefault();
         student.GroupId = -1;
         db.SubmitChanges();
         BindData();
     }
 }
 protected void AddUserToGroup(object sender, CommandEventArgs e)
 {
     string id = Request.QueryString["id"];
     using (var db = new DataBase.DataClasses1DataContext(WebConfigurationManager.ConnectionStrings["dziennikucznia_studentlive_plConnectionString"].ConnectionString))
     {
         var student = (from s in db.aspnet_Memberships where s.UserId == new Guid(e.CommandArgument.ToString()) select s).FirstOrDefault();
         student.GroupId = Convert.ToInt32(id);
         db.SubmitChanges();
         BindData();
     }
 }
Ejemplo n.º 3
0
 protected void AddGroupButton_Click(object sender, EventArgs e)
 {
     using (var db = new DataBase.DataClasses1DataContext(WebConfigurationManager.ConnectionStrings["dziennikucznia_studentlive_plConnectionString"].ConnectionString))
     {
         Group @group = new Group();
         @group.Name = GroupNameTextBox.Text;
         db.Groups.InsertOnSubmit(@group);
         db.SubmitChanges();
         GroupNameRepeater.DataBind();
     }
 }
        protected void EditProblemX_Click(object sender, EventArgs e)
        {
            // dodawanie nowego zadania /////////////////////////////////////////////////////////////////
            if (KodProblemu == null)
            {
                if (Page.IsValid)
                {
                    string inputs = "";
                    string outputs = "";

                    if (CSVinputs != null && CSVoutputs != null)
                    {
                        inputs = CSVinputs;
                        outputs = CSVoutputs;
                    }
                    else
                    {
                        for (int i = 1; i < InOut.Rows.Count; i++)
                        {
                            TextBox Input = (TextBox)InOut.Rows[i].Cells[1].Controls[0];
                            TextBox Output = (TextBox)InOut.Rows[i].Cells[2].Controls[0];

                            if ((Input.Text == "" && Output.Text != "") || (Input.Text != "" && Output.Text == ""))
                            {
                                EditSuccessful.Text = "Niektóre z twoich par wej-wyj są niekompletne!";
                                EditSuccessful.Visible = true;
                                return;
                            }
                            else if (Input.Text == "" && Output.Text == "")
                            {
                                continue;
                            }

                            inputs += Input.Text + ";";
                            outputs += Output.Text + ";";
                        }
                    }

                    if (inputs == "")
                    {
                        EditSuccessful.Text = "Nie podałeś sekwencji wyjściowych!";
                        EditSuccessful.Visible = true;
                        return;
                    }
                    else if (outputs == "")
                    {
                        EditSuccessful.Text = "Nie podałeś sekwencji wejściowych!";
                        EditSuccessful.Visible = true;
                        return;
                    }

                    var db = new DataBase.DataClasses1DataContext();

                    DataBase.Problem NewProblem = new DataBase.Problem();

                    NewProblem.Title = ProblemsTitle.Text;
                    NewProblem.ProblemsCode = ProblemsCode.Text;
                    NewProblem.Description = Editor.Content;
                    NewProblem.DifficultyLevel = DifficultyLevel.SelectedItem.Text;

                    //pobranie dozwolonych języków programowania z kontrolki CheckBoxList do
                    //stringu languages
                    string languages = "";

                    for (int i = 0; i < Languages.Items.Count; i++)
                    {
                        if (Languages.Items[i].Selected)
                        {
                            languages += Languages.Items[i].Text + ";";
                        }
                    }

                    //zbieranie grup
                    string groups = "";

                    for (int i = 0; i < Groups.Items.Count; i++)
                    {
                        groups += Groups.Items[i].Text + ";";
                    }

                    //sprawdzenie czy został wybrany jakikolwiek język programowania
                    if (languages == "")
                    {
                        EditSuccessful.Text = "Wybierz przynajmniej jeden dozwolony język programowania";
                        EditSuccessful.Visible = true;
                        return;
                    }

                    NewProblem.Input = inputs;
                    NewProblem.Output = outputs;

                    NewProblem.Languages = languages;

                    NewProblem.TimeLimit = int.Parse(TimeLimit.Text);
                    NewProblem.SizeLimit = int.Parse(SizeLimit.Text);

                    NewProblem.OpeningDate = Convert.ToDateTime(OpeningDate.Text + " " + Convert.ToString(OpeningTime.Date.TimeOfDay));
                    NewProblem.ClosingDate = Convert.ToDateTime(ClosingDate.Text + " " + Convert.ToString(ClosingTime.Date.TimeOfDay));

                    NewProblem.AddingDate = DateTime.Now;
                    NewProblem.AddedBy = "Admin";

                    NewProblem.Groups = groups;

                    db.Problems.InsertOnSubmit(NewProblem);
                    db.SubmitChanges();
                }
            }

            // edycja istniejącego zadania /////////////////////////////////////////////////////////////////////////
            else
            {
                if (Page.IsValid)
                {
                    string newInput = "";
                    string newOutput = "";

                    if (CSVinputs != null && CSVoutputs != null)
                    {
                        newInput = CSVinputs;
                        newOutput = CSVoutputs;
                    }
                    else
                    {
                        for (int i = 1; i < InOut.Rows.Count; i++)
                        {
                            TextBox Input = (TextBox)InOut.Rows[i].Cells[1].Controls[0];
                            TextBox Output = (TextBox)InOut.Rows[i].Cells[2].Controls[0];

                            if ((Input.Text == "" && Output.Text != "") || (Input.Text != "" && Output.Text == ""))
                            {
                                EditSuccessful.Text = "Niektóre z twoich par wej-wyj są niekompletne!";
                                EditSuccessful.Visible = true;
                                return;
                            }
                            else if (Input.Text == "" && Output.Text == "")
                            {
                                continue;
                            }

                            newInput += Input.Text + ";";
                            newOutput += Output.Text + ";";
                        }
                    }

                    if (newOutput == "")
                    {
                        EditSuccessful.Text = "Nie podałeś sekwencji wyjściowych!";
                        EditSuccessful.Visible = true;
                        return;
                    }
                    else if (newInput == "")
                    {
                        EditSuccessful.Text = "Nie podałeś sekwencji wejściowych!";
                        EditSuccessful.Visible = true;
                        return;
                    }

                    var db = new DataBase.DataClasses1DataContext();

                    var query = from n in db.Problems where n.ProblemsCode == KodProblemu select n;

                    var ExistingProblem = query.First();

                    ExistingProblem.Title = ProblemsTitle.Text;
                    ExistingProblem.ProblemsCode = ProblemsCode.Text;
                    ExistingProblem.Description = Editor.Content;
                    ExistingProblem.DifficultyLevel = DifficultyLevel.SelectedItem.Text;

                    ExistingProblem.Input = newInput;
                    ExistingProblem.Output = newOutput;

                    //pobranie dozwolonych języków programowania z kontrolki CheckBoxList do
                    //stringu languages
                    string languages = "";

                    for (int i = 0; i < Languages.Items.Count; i++)
                    {
                        if (Languages.Items[i].Selected == true)
                        {
                            languages += Languages.Items[i].Text + ";";
                        }
                    }

                    //sprawdzenie czy został wybrany jakikolwiek język programowania
                    if (languages == "")
                    {
                        EditSuccessful.Text = "Wybierz przynajmniej jeden dozwolony język programowania";
                        EditSuccessful.Visible = true;
                        return;
                    }

                    ExistingProblem.Languages = languages;

                    //zbieranie grup
                    string groups = "";

                    for (int i = 0; i < Groups.Items.Count; i++)
                    {
                        if (Groups.Items[i].Selected == true)
                        {
                            groups += Groups.Items[i].Text + ";";
                        }
                    }

                    ExistingProblem.Groups = groups;

                    ExistingProblem.TimeLimit = int.Parse(TimeLimit.Text);
                    ExistingProblem.SizeLimit = int.Parse(SizeLimit.Text);

                    ExistingProblem.OpeningDate = Convert.ToDateTime(OpeningDate.Text + " " + Convert.ToString(OpeningTime.Date.TimeOfDay));
                    ExistingProblem.ClosingDate = Convert.ToDateTime(ClosingDate.Text + " " + Convert.ToString(ClosingTime.Date.TimeOfDay));

                    ExistingProblem.AddingDate = DateTime.Now;
                    ExistingProblem.AddedBy = "Admin";
                    db.SubmitChanges();
                }
            }

            MultiView1.ActiveViewIndex = 1;
        }