partial void DeleteContestSetting(ContestSetting instance);
 partial void InsertContestSetting(ContestSetting instance);
 partial void UpdateContestSetting(ContestSetting instance);
    private void Save()
    {
        if (ViewState["mode"].ToString() == "Add")
        {
            ContestSetting cs = new ContestSetting();
            cs.Name = txtName.Text;
            cs.ArrangedBy = txtArrangeBy.Text;
            cs.StartTime = Convert.ToDateTime(txtStartTime.Text);
            cs.EndTime = Convert.ToDateTime(txtEndTime.Text);
            cs.IsPrivate = cbIsPrivate.Checked;

            ProgrammingContestDataContextHandler pcdch = new ProgrammingContestDataContextHandler();
            pcdch.ProgrammingContestDatabase.ContestSettings.InsertOnSubmit(cs);
            pcdch.ProgrammingContestDatabase.SubmitChanges();

            rptProblems.DataSource = pcdch.ContestSetting.GetAll();
            rptProblems.DataBind();

        }
        else if (ViewState["mode"].ToString() == "Edit")
        {
            ProgrammingContestDataContextHandler pcdch = new ProgrammingContestDataContextHandler();
            ContestSetting cs = pcdch.ContestSetting.GetById(Convert.ToInt64(ViewState["ID"].ToString()));
            cs.Name = txtName.Text;
            cs.ArrangedBy = txtArrangeBy.Text;
            cs.StartTime = Convert.ToDateTime(txtStartTime.Text);
            cs.EndTime = Convert.ToDateTime(txtEndTime.Text);
            cs.IsPrivate = cbIsPrivate.Checked;

            pcdch.ProgrammingContestDatabase.SubmitChanges();

            rptProblems.DataSource = pcdch.ContestSetting.GetAll();
            rptProblems.DataBind();
        }

        mvProblem.ActiveViewIndex = 0;
    }