Пример #1
0
        //private void fillTeamsGridWithCompetitionType(string competition_type)
        //{
        //    TeamsController tm = new TeamsController();
        //    DataTable dt = new DataTable();
        //    dt = tm.GetAllTeamsWithCompetitionType(currentUser.Username, competition_type);


        //    int teamId = 0;
        //    int.TryParse(ddlTeamSearch.SelectedValue.ToString(), out teamId);
        //    if (teamId != null && teamId > 0)
        //    {
        //        DataView dv = new DataView();
        //        dv = dt.AsDataView();
        //        dv.RowFilter = " TeamID = " + teamId;
        //        dt = dv.ToTable();
        //    }

        //    grid_Teams.DataSource = dt;
        //    grid_Teams.DataBind();

        //}

        private void SaveTeam()
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "SaveSuccessfully();", true);

            #region Add Selected Teams In Competition Team Table

            foreach (RepeaterItem i in rptrForTeams.Items)
            {
                HiddenField hdnTeamMasterID = (HiddenField)i.FindControl("hdnTeamID");
                CheckBox    chk_Assign_team = (CheckBox)i.FindControl("chk_Assign_team");

                if (chk_Assign_team.Checked)
                {
                    Boolean FileOK    = false;
                    Boolean FileSaved = false;
                    int     group_id  = 0;
                    if (ddlGroupName.SelectedIndex > 0)
                    {
                        int.TryParse(ddlGroupName.SelectedValue, out group_id);
                    }
                    ctClass.CompetitionGroupId = group_id;
                    ctClass.CompetitionId      = CompetitionID;

                    int MasterID = 0;
                    int.TryParse(hdnTeamMasterID.Value, out MasterID);

                    ctClass.TeamId       = MasterID;
                    ctClass.CreatedById  = currentUser.Username;
                    ctClass.ModifiedById = currentUser.Username;
                    ctController.InsertCompetitionTeam(ctClass);
                }
            }

            #endregion

            FillCompetitionTeamGrid();
        }
        protected void btnSaveCompetition_Click(object sender, EventArgs e)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "SaveSuccessfully();", true);

            cl.CompetitionName     = txtCompetition.Text.Trim();
            cl.CompetitionAbbr     = txtCompetitionAbbr.Text;
            cl.CompetitionDesc     = txtCompetitionDesc.Text.Trim();
            cl.CompetitionLogoName = txtCompetitionLogoName.Text;

            int.TryParse(ddlSeason.SelectedValue, out cl.SeasonId);
            int.TryParse(ddlCompetitionLeague.SelectedValue, out cl.CompeitionLeagueId);
            int.TryParse(ddlCompetitionType.SelectedValue, out cl.CompetitionTypeId);
            int.TryParse(ddlCompetitionFormat.SelectedValue, out cl.CompetitionFormatId);
            int.TryParse(ddlSport.SelectedValue, out cl.SportId);
            int.TryParse(ddlDivision.SelectedValue, out cl.DivisionId);

            int.TryParse(txtNoOfGroup.Text, out cl.NumberofGroups);
            int.TryParse(txtNoOfTeam.Text, out cl.NumberofTeams);

            cl.StartDate = (txtStartDate.Text != "" ? Convert.ToDateTime(txtStartDate.Text, new System.Globalization.CultureInfo("en-GB")) : DateTime.MinValue);
            cl.EndDate   = (txtEndDate.Text != "" ? Convert.ToDateTime(txtEndDate.Text, new System.Globalization.CultureInfo("en-GB")) : DateTime.MinValue);

            cl.CompetitionLogoFile = imhpathDB + CompetitionLogoFile.PostedFile.FileName.Replace(" ", "");

            if (CompetitionLogoFile.PostedFile != null)
            {
                String   FileExtension     = Path.GetExtension(CompetitionLogoFile.PostedFile.FileName.Replace(" ", "")).ToLower();
                String[] allowedExtensions = { ".png", ".jpg", ".gif", ".jpeg" };
                for (int i = 0; i < allowedExtensions.Length; i++)
                {
                    if (FileExtension == allowedExtensions[i])
                    {
                        FileOK = true;
                        break;
                    }
                }
            }

            if (!string.IsNullOrEmpty(CompetitionLogoFile.PostedFile.FileName))
            {
                if (!FileOK)
                {
                    //Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Please choose only .jpg, .png and .gif images For Competition !')", true);
                    return;
                }
            }

            if (FileOK)
            {
                if (CompetitionLogoFile.PostedFile.ContentLength > 10485760)
                {
                    //dvMsg.Attributes.Add("style", "display:block;");
                    //return;
                }
                else
                {
                    //dvMsg.Attributes.Add("style", "display:none;");
                }

                try
                {
                    CompetitionLogoFile.PostedFile.SaveAs(physicalpath + ImageUploadFolder + CompetitionLogoFile.PostedFile.FileName.Replace(" ", ""));
                    FileSaved = true;
                }
                catch (Exception ex)
                {
                    FileSaved = false;
                }
            }


            cl.ActiveFlagId = Convert.ToInt32(ChkIsActive.Checked);
            cl.ShowFlagId   = Convert.ToInt32(ChkIsShow.Checked);
            cl.PortalID     = PortalId;
            cl.CreatedById  = currentUser.Username;
            cl.ModifiedById = currentUser.Username;

            int resVal = 0;

            if (!string.IsNullOrEmpty(txtWin.Text))
            {
                int.TryParse(txtWin.Text, out resVal);
            }
            cl.WinPoint = resVal;

            resVal = 0;
            if (!string.IsNullOrEmpty(txtLose.Text))
            {
                int.TryParse(txtLose.Text, out resVal);
            }
            cl.LossPoint = resVal;

            if (!string.IsNullOrEmpty(txtDraw.Text))
            {
                resVal = 0;
            }
            int.TryParse(txtDraw.Text, out resVal);
            cl.DrawPoint = resVal;

            resVal = 0;
            int.TryParse(txtNoShowGoal.Text, out resVal);
            cl.NoShowGoalPoint = resVal;

            // Call Save Method
            int Inserted_Competition_Id = clc.InsertCompetition(cl);

            if (ddlDivision.SelectedIndex > 0)
            {
                // Insert Selected Division Teams into Competition Teams
                using (DataTable division_teams = dtController.GetDivisionTeamsByUser(currentUser.Username, cl.DivisionId, 0))
                {
                    for (int i = 0; i < division_teams.Rows.Count; i++)
                    {
                        int.TryParse(division_teams.Rows[i]["TeamId"].ToString(), out ctClass.TeamId);

                        ctClass.CompetitionGroupId = 0;
                        ctClass.CompetitionId      = Inserted_Competition_Id;
                        ctClass.CreatedById        = currentUser.Username;
                        ctClass.ModifiedById       = currentUser.Username;
                        cteamController.InsertCompetitionTeam(ctClass);
                    }
                }
            }


            btnAddCompetition.Visible  = true;
            pnlCompetitionGrid.Visible = true;
            LoadCompetitionGrid();
            ClearData();
        }