コード例 #1
0
        protected void DeleteButtonClick(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            {
                int iD = Convert.ToInt32(button.CommandArgument);
                CompetitionDataContext competitionDataBase  = new CompetitionDataContext();
                zConstantListTable     constantListToDelete = (from a in competitionDataBase.zConstantListTable
                                                               where a.ID == iD
                                                               select a).FirstOrDefault();
                List <zCollectedDataTable> constatvalue = (from a in competitionDataBase.zCollectedDataTable
                                                           where a.Active && a.FK_ConstantListTable == constantListToDelete.ID
                                                           select a).ToList();
                if (constantListToDelete != null)
                {
                    constantListToDelete.Active = false;
                    competitionDataBase.SubmitChanges();
                    foreach (zCollectedDataTable n in constatvalue)
                    {
                        n.Active = false;
                        competitionDataBase.SubmitChanges();
                    }
                }
                else
                {
                    //error
                }
            }
            Response.Redirect("ChooseConstantList.aspx");
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var sessionParam1 = Session["CompetitionID"];
            var sessionParam2 = Session["ConstantListID"];

            if ((sessionParam1 == null) || (sessionParam2 == null))
            {   //error
                Response.Redirect("ChooseConstantList.aspx");
            }
            int competitionId  = (int)sessionParam1;
            int constantListId = (int)sessionParam2;

            if (!Page.IsPostBack)
            {
                CompetitionDataContext competitionDataBase = new CompetitionDataContext();

                zConstantListTable currenConstantList = (from a in competitionDataBase.zConstantListTable
                                                         where a.ID == constantListId
                                                         select a).FirstOrDefault();

                ConstantListNameTextBox.Text = currenConstantList.Name;

                DataTable dataTable = new DataTable();
                dataTable.Columns.Add(new DataColumn("ID", typeof(string)));
                dataTable.Columns.Add(new DataColumn("ConstValue", typeof(string)));

                List <zCollectedDataTable> constantCollectedDate = (from a in competitionDataBase.zCollectedDataTable
                                                                    where a.Active == true
                                                                    join b in competitionDataBase.zConstantListTable
                                                                    on a.FK_ConstantListTable equals b.ID
                                                                    where b.Active == true &&
                                                                    b.ID == constantListId &&
                                                                    b.FK_CompetitionTable == competitionId
                                                                    select a).ToList();


                foreach (zCollectedDataTable currentCollectedData in constantCollectedDate)
                {
                    DataRow dataRow = dataTable.NewRow();
                    dataRow["ID"]         = currentCollectedData.ID;
                    dataRow["ConstValue"] = currentCollectedData.ValueText;
                    dataTable.Rows.Add(dataRow);
                }

                ConstantListValuesGV.DataSource = dataTable;
                ConstantListValuesGV.DataBind();
            }
        }
コード例 #3
0
        protected void CreateNewConstanListButton_Click(object sender, EventArgs e)
        {
            var sessionParam1 = Session["CompetitionID"];

            if (sessionParam1 == null)
            {   //error
                Response.Redirect("ChooseConstantList.aspx");
            }
            int competitionId = (int)sessionParam1;

            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            zConstantListTable     newConstantList     = new zConstantListTable();

            newConstantList.FK_CompetitionTable = competitionId;
            newConstantList.Active = true;
            newConstantList.Name   = "";
            competitionDataBase.zConstantListTable.InsertOnSubmit(newConstantList);
            competitionDataBase.SubmitChanges();

            Session["ConstantListID"] = newConstantList.ID;
            Response.Redirect("ConstantListCreate.aspx");
        }
コード例 #4
0
        protected void SaveAllButton_Click(object sender, EventArgs e)
        {
            CompetitionDataContext competitionDataBase = new CompetitionDataContext();
            var sessionParam1 = Session["CompetitionID"];
            var sessionParam2 = Session["ConstantListID"];

            if ((sessionParam1 == null) || (sessionParam2 == null))
            {   //error
                Response.Redirect("ChooseConstantList.aspx");
            }
            int competitionId  = (int)sessionParam1;
            int constantListId = (int)sessionParam2;

            DataType dataType = new DataType();

            foreach (GridViewRow currentRow in ConstantListValuesGV.Rows)
            {
                Label idLabel = (Label)currentRow.FindControl("ID");
                if (idLabel != null)
                {
                    zCollectedDataTable currentCollectedData = (from a in competitionDataBase.zCollectedDataTable
                                                                where a.ID == Convert.ToInt32(idLabel.Text)
                                                                select a).FirstOrDefault();

                    if (currentCollectedData != null)
                    {
                        TextBox currentTextBox = (TextBox)currentRow.FindControl("ConstValueTextBox");
                        currentCollectedData.ValueText = currentTextBox.Text;
                        competitionDataBase.SubmitChanges();
                    }
                }
            }
            zConstantListTable currentConstantList = (from a in competitionDataBase.zConstantListTable
                                                      where a.ID == constantListId
                                                      select a).FirstOrDefault();

            currentConstantList.Name = ConstantListNameTextBox.Text;
            competitionDataBase.SubmitChanges();
        }