Ejemplo n.º 1
0
        private void LoadSeasonTeamCombo()
        {
            var ds = SeasonTeamBLL.SeasonTeamOrder(Convert.ToInt32(rDDSeason.SelectedValue));

            rDDSeasonTeam.Items.Clear();
            rDDSeasonTeam.DataSource     = ds;
            rDDSeasonTeam.DataValueField = "TeamID";
            rDDSeasonTeam.DataTextField  = "TeamName";
            rDDSeasonTeam.DataBind();

            rDDMyPositionType.SelectedValue = ds.FirstOrDefault().TeamID.ToString();
        }
Ejemplo n.º 2
0
        protected void rGridTeam_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                //GridDataItem dataItem = e.Item as GridDataItem;
                int fieldValue = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "Points").ToString());
                totPointCount += fieldValue;

                RadBinaryImage rPrimPos = (RadBinaryImage)e.Item.FindControl("imgPrimPositon");
                RadBinaryImage rSecPos  = (RadBinaryImage)e.Item.FindControl("imgSecPositon");

                rPrimPos.ImageUrl = "~/Content/images/" + DataBinder.Eval(e.Item.DataItem, "PrimPos").ToString().Trim() + ".jpg";
                if (DataBinder.Eval(e.Item.DataItem, "SecPos") != null)
                {
                    rSecPos.ImageUrl = "~/Content/images/" + DataBinder.Eval(e.Item.DataItem, "SecPos").ToString().Trim() + ".jpg";
                }
                else
                {
                    rSecPos.Visible = false;
                }
            }
            if (e.Item is GridFooterItem)
            {
                GridFooterItem footerItem = e.Item as GridFooterItem;
                footerItem["Points"].Text = "total: " + totPointCount.ToString();
            }
            else if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                GridEditableItem edtItem     = (GridEditableItem)e.Item;
                Label            lblSeasonID = (Label)edtItem.FindControl("lblSeasonID");
                Label            lblTeamID   = (Label)edtItem.FindControl("lblTeamID");

                RadDropDownList rDDSeasonTeam = (RadDropDownList)edtItem.FindControl("rDDSeasonTeam");
                rDDSeasonTeam.DataSource     = SeasonTeamBLL.SeasonTeamOrder(Convert.ToInt32(lblSeasonID.Text));
                rDDSeasonTeam.DataValueField = "TeamID";
                rDDSeasonTeam.DataTextField  = "TeamName";
                rDDSeasonTeam.DataBind();
                rDDSeasonTeam.SelectedValue = lblTeamID.Text.ToString();
            }
        }
Ejemplo n.º 3
0
        protected void LoadrDDSeasonTeam()
        {
            //  Manually load dropdown list
            try
            {
                List <SeasonTeamDomainModel> ds = SeasonTeamBLL.SeasonTeamOrder(Convert.ToInt32(rDDSeason.SelectedValue)).OrderBy(o => o.TeamName).ToList();

                rDDSeasonTeam.Items.Clear();

                var itemRecycle = new DropDownListItem("Recycle Bin", "0");
                rDDSeasonTeam.Items.Add(itemRecycle);
                foreach (var element in ds)
                {
                    var item = new DropDownListItem(element.TeamName.ToString(), element.TeamID.ToString());
                    if (CanTeamBid(element.SeasonID, element.TeamID, element.MaxBid))
                    {
                        item.Enabled = true;
                    }
                    else
                    {
                        item.Enabled   = false;
                        item.BackColor = System.Drawing.Color.LightBlue;
                    }
                    rDDSeasonTeam.Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                StackTrace st        = new StackTrace();
                StackFrame sf        = st.GetFrame(0);
                string     errMethod = sf.GetMethod().Name.ToString();                                           // Get the current method name
                string     errMsg    = "600";                                                                    // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                                                                   // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                                                                          // Go to the error page.
            }
        }
Ejemplo n.º 4
0
        protected void rGridDraftPlayer_ItemCommand(object sender, GridCommandEventArgs e)
        {
            if (e.CommandName == "TestEmail")
            {
                try
                {
                    string     strFileName = CSBA.BusinessLogicLayer.Logic.cExcel.CreateSpreadsheet(1031);
                    Attachment att         = new Attachment(strFileName);
                    cMail.SendMessage("*****@*****.**", "*****@*****.**", "CSBA Test Email", "Test Body", strFileName, att);
                }
                catch (Exception ex)
                {
                    StackTrace st        = new StackTrace();
                    StackFrame sf        = st.GetFrame(0);
                    string     errMethod = sf.GetMethod().Name.ToString();                                           // Get the current method name
                    string     errMsg    = "600";                                                                    // Gotta pass something, we're retro-fitting an existing method
                    Session["LastException"] = ex;                                                                   // Throw the exception in the session variable, will be used in error page
                    string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                    Response.Redirect(url);                                                                          // Go to the error page.
                }
            }

            if (e.CommandName == "CreateSpreadsheets")
            {
                List <SeasonDomainModel> Seasons       = new List <SeasonDomainModel>();
                TeamBusinessLogicLayer   TeamBLL       = new TeamBusinessLogicLayer();
                SeasonTeamBusinessLogic  SeasonTeamBLL = new SeasonTeamBusinessLogic();

                Seasons = SeasonBLL.ListSeason();
                int SeasonID = 0;
                foreach (SeasonDomainModel season in Seasons)
                {
                    if (season.CurrentSeason == true)
                    {
                        SeasonID = season.SeasonID;
                        break;
                    }
                }

                Excel.Application myApp = new Excel.Application();
                myApp.Visible = true;
                Excel.Workbook wb = myApp.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorksheet);


                List <SeasonTeamDomainModel> listSeasonTeam = SeasonTeamBLL.SeasonTeamOrder(SeasonID);

                foreach (SeasonTeamDomainModel st in listSeasonTeam)
                {
                    Excel.Worksheet ws = (Excel.Worksheet)wb.Worksheets.Add();
                    ws.Name = st.TeamName.Trim();

                    List <v_Team_Draft_RosterDomainModel> ListTeam = TeamBLL.ListTeamRoster(SeasonID, st.TeamID);

                    int iRow = 1;
                    ws.Cells[iRow, 1] = "Primary Position";
                    ws.Cells[iRow, 2] = "Secondary Position";
                    ws.Cells[iRow, 3] = "Player Name";
                    ws.Cells[iRow, 4] = "Points";
                    iRow++;
                    foreach (v_Team_Draft_RosterDomainModel TDraft in ListTeam)
                    {
                        ws.Cells[iRow, 1] = TDraft.PrimPos.Trim();
                        if (TDraft.SecPos != null)
                        {
                            ws.Cells[iRow, 2] = TDraft.SecPos.Trim();
                        }
                        ws.Cells[iRow, 3] = TDraft.PlayerName.Trim();
                        ws.Cells[iRow, 4] = TDraft.Points;
                        iRow++;
                    }
                }
            }


            if (e.CommandName == "EmailRosters")
            {
                string strFileName = CSBA.BusinessLogicLayer.Logic.cExcel.CreateSpreadsheet(Convert.ToInt32(rDDSeason.SelectedValue));

                foreach (GridDataItem item in rGridDraftPlayer.Items)
                {
                    try
                    {
                        StringBuilder          sb      = new StringBuilder();
                        TeamBusinessLogicLayer TeamBLL = new TeamBusinessLogicLayer();
                        RadButton rBTNTeamName         = (RadButton)item.FindControl("rBTNTeamName");
                        Label     lblOwnerEmail        = (Label)item.FindControl("lblOwnerEmail");
                        Label     lblTeamID            = (Label)item.FindControl("lblTeamID");
                        List <v_Team_Draft_RosterDomainModel> TeamDraft = TeamBLL.ListTeamRoster(Convert.ToInt32(rDDSeason.SelectedValue), Convert.ToInt32(lblTeamID.Text));

                        sb.Append("<table><p class=border>");
                        sb.Append("<tr>");
                        sb.Append("<td><b><p class=border>");
                        sb.Append("Player Name");
                        sb.Append("</b></td>");
                        sb.Append("<td><b><p class=border>");
                        sb.Append("Primary Position  ");
                        sb.Append("</b></td>");
                        sb.Append("<td><b><p class=border>");
                        sb.Append("Secondary Position  ");
                        sb.Append("</b></td>");
                        sb.Append("<td><b><p class=border>");
                        sb.Append("Points   ");
                        sb.Append("</b></td>");

                        foreach (v_Team_Draft_RosterDomainModel TeamPlayer in TeamDraft)
                        {
                            sb.Append("<tr>");
                            sb.Append("<td>");
                            sb.Append("<div align=left><p class=border>");
                            sb.Append(TeamPlayer.PlayerName.Trim());
                            sb.Append("</td>");
                            sb.Append("<td>");
                            sb.Append("<div align=left><p class=border>");
                            sb.Append(TeamPlayer.PrimPos.Trim());
                            sb.Append("</td>");
                            sb.Append("<td>");
                            sb.Append("<div align=left><p class=border>");
                            if (TeamPlayer.SecPos == null)
                            {
                                sb.Append("n/a");
                            }
                            else
                            {
                                sb.Append(TeamPlayer.SecPos.Trim());
                            }
                            sb.Append("</td>");
                            sb.Append("<td>");
                            sb.Append("<div align=right><p class=border>");
                            sb.Append(TeamPlayer.Points.ToString().Trim());
                            sb.Append("</td>");
                            sb.Append("</tr>");
                        }

                        sb.Append("</table>");

                        string[,] MergeValues = new string[, ] {
                            { "{TeamName}", rBTNTeamName.Text.Trim() }, { "{TeamRoster}", sb.ToString() }
                        };


                        //Attachment att = null;// = new Attachment(strFileName);

                        if (strFileName != null)
                        {
                            Attachment         att         = new System.Net.Mail.Attachment(strFileName, System.Net.Mime.MediaTypeNames.Application.Octet);
                            ContentDisposition disposition = att.ContentDisposition;
                            disposition.CreationDate     = File.GetCreationTime(strFileName);
                            disposition.ModificationDate = File.GetLastWriteTime(strFileName);
                            disposition.ReadDate         = File.GetLastAccessTime(strFileName);
                            disposition.FileName         = Path.GetFileName(strFileName.Trim());
                            disposition.Size             = new FileInfo(strFileName).Length;
                            disposition.DispositionType  = DispositionTypeNames.Attachment;

                            cMail.SendMessage("*****@*****.**", lblOwnerEmail.Text.ToString().Trim(), "CSBA Roster", cMail.PopulateBody("~/Content/EmailTemplates/DraftRoster.html", MergeValues), strFileName, att);
                        }
                    }
                    catch (Exception ex)
                    {
                        StackTrace st        = new StackTrace();
                        StackFrame sf        = st.GetFrame(0);
                        string     errMethod = sf.GetMethod().Name.ToString();                                           // Get the current method name
                        string     errMsg    = "600";                                                                    // Gotta pass something, we're retro-fitting an existing method
                        Session["LastException"] = ex;                                                                   // Throw the exception in the session variable, will be used in error page
                        string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                        Response.Redirect(url);                                                                          // Go to the error page.
                    }
                }
            }
        }