예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Int16 pagenumber = 1;
                Int16 pagesize   = 10;
                Int64 salesrepid = 0;

                Int16 viewmode    = 0;
                Int16 relatedmode = 0;

                string relatedkeyword = "";
                string keyword = "";
                string datefrom, dateto;
                datefrom = ""; dateto = "";

                if (Request.QueryString["PageNumber"] != null)
                {
                    pagenumber = Convert.ToInt16(Request.QueryString["PageNumber"]);
                }
                if (Request.QueryString["PageSize"] != null)
                {
                    pagesize = Convert.ToInt16(Request.QueryString["PageSize"]);
                }
                if (Request.QueryString["SalesRepID"] != null)
                {
                    salesrepid = Convert.ToInt64(Request.QueryString["SalesRepID"]);
                }

                if (Request.QueryString["DateFrom"] != null)
                {
                    datefrom = Request.QueryString["DateFrom"];
                }
                if (Request.QueryString["DateTo"] != null)
                {
                    dateto = Request.QueryString["DateTo"];
                }

                if (Request.QueryString["ViewMode"] != null)
                {
                    if (Request.QueryString["ViewMode"].ToUpper() == "ALL")
                    {
                        viewmode = 0;
                    }
                    else if (Request.QueryString["ViewMode"].ToUpper() == "PROSPECT")
                    {
                        viewmode = 1;
                    }
                    else if (Request.QueryString["ViewMode"].ToUpper() == "HOST")
                    {
                        viewmode = 2;
                    }
                    else if (Request.QueryString["ViewMode"].ToUpper() == "EVENT")
                    {
                        viewmode = 3;
                    }
                }
                if (Request.QueryString["RelatedMode"] != null)
                {
                    if (Request.QueryString["RelatedMode"].ToUpper() == "PROSPECT")
                    {
                        relatedmode = 1;
                    }
                    else if (Request.QueryString["RelatedMode"].ToUpper() == "HOST")
                    {
                        relatedmode = 2;
                    }
                    else if (Request.QueryString["RelatedMode"].ToUpper() == "CONTACT")
                    {
                        relatedmode = 3;
                    }
                    else if (Request.QueryString["RelatedMode"].ToUpper() == "EVENT")
                    {
                        relatedmode = 4;
                    }
                }
                if (Request.QueryString["RelatedKeyword"] != null)
                {
                    relatedkeyword = Request.QueryString["RelatedKeyword"];
                }


                if (Request.QueryString["Keyword"] != null)
                {
                    keyword = Request.QueryString["Keyword"];
                }

                //FranchiseeService objservice = new HealthYes.Web.UI.FranchiseeService.FranchiseeService();
                FranchiseeDAL franchiseeDAL = new FranchiseeDAL();
                List <ESalesRepMyActivity> arrsalesrepmyactivity = null;

                long totalrecords;

                if (Request.QueryString["SearchMode"] != null)
                {
                    arrsalesrepmyactivity = franchiseeDAL.GetSalesRepMyActivityInfo(salesrepid, pagenumber, pagesize, datefrom, dateto, relatedkeyword, relatedmode, keyword, true, viewmode, out totalrecords, 1);
                }
                else
                {
                    arrsalesrepmyactivity = franchiseeDAL.GetSalesRepMyActivityInfo(salesrepid, pagenumber, pagesize, "", "", "", 0, "", false, viewmode, out totalrecords, 1);
                }

                if (arrsalesrepmyactivity != null)
                {
                    FillGridforMyActivity(arrsalesrepmyactivity);
                    string pagingstring = ImplementPaging(pagenumber, pagesize, totalrecords);

                    HtmlForm Formnew = this.Page.Form;
                    Formnew.Controls.Clear();
                    Formnew.Controls.Add(grdMyActivities);

                    System.Text.StringBuilder sb       = new System.Text.StringBuilder();
                    HtmlTextWriter            htWriter = new HtmlTextWriter(new System.IO.StringWriter(sb));

                    Formnew.RenderControl(htWriter);

                    string strRenderedHTML = sb.ToString();
                    int    startindex      = strRenderedHTML.IndexOf("<table");
                    int    endindex        = strRenderedHTML.IndexOf("</table>");
                    int    length          = (endindex - startindex) + 8;
                    strRenderedHTML = strRenderedHTML.Substring(startindex, length);

                    strRenderedHTML = "<div style='float: left; width: 746px'>" + strRenderedHTML + "</div>";

                    Response.Write(strRenderedHTML + pagingstring + "<p class=\"blueboxbotbg_cl\"><img src=\"/App/Images/specer.gif\" width=\"746\" height=\"5\" /></p>");
                }
                else
                {
                    Response.Write("<div id=\"divNoRecords\" style=\"float: left; width: 714px; display: block; padding: 10px 10px 10px 20px; border: solid 1px #DFEEF5;\"><div class=\"divnoitemfound1_custdbrd\"><p class=\"divnoitemtxt_custdbrd\"><span class=\"orngbold18_default\">No Record Found</span></p></div></div>");
                }
                //else
                //{
                //    HtmlForm Formnew = this.Page.Form;
                //    Formnew.Controls.Clear();

                //    activityMessage.ShowErrorMessage("No Records Found.");
                //    activityDiv.Style.Add(HtmlTextWriterStyle.Display, "block");

                //    Formnew = this.Page.Form;
                //    Formnew.Controls.Clear();
                //    Formnew.Controls.Add(activityDiv);

                //    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                //    HtmlTextWriter htWriter = new HtmlTextWriter(new System.IO.StringWriter(sb));
                //    Formnew.RenderControl(htWriter);

                //    string strRenderedHTML = sb.ToString();
                //    int startindex = strRenderedHTML.IndexOf("<div id=\"activityDiv\"");
                //    int endindex = strRenderedHTML.IndexOf("</div>");
                //    int length = (endindex - startindex) + 6;
                //    strRenderedHTML = strRenderedHTML.Substring(startindex, length);

                //    Response.Write(strRenderedHTML);
                //}
            }
            catch (Exception ex)
            {
                //Response.Write("<span style='float:left; padding:5px; font-size:14px'> <b> Some Error occured, data could not be loaded. </b> </span>");
                Response.Write("<span style='float:left; padding:5px; font-size:14px'> <b> " + ex.Message + "</b> </span>");
            }
            finally
            {
                Response.End();
            }
        }
예제 #2
0
        private void LoadTodayActivity()
        {
            long totalrecords  = 0;
            var  todayActivity = franchiseeDal.GetSalesRepMyActivityInfo(IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole.OrganizationRoleUserId, 0, 0, "", "", "", 0, "", false, 0, out totalrecords, 2);

            DataTable dtactivities = new DataTable();

            dtactivities.Columns.Add("ActivityID");
            dtactivities.Columns.Add("ContactID");
            dtactivities.Columns.Add("ProspectID");
            dtactivities.Columns.Add("ProspectContactID");
            dtactivities.Columns.Add("Prospect");
            dtactivities.Columns.Add("Contact");
            dtactivities.Columns.Add("Subject");
            dtactivities.Columns.Add("ActivityTime");
            dtactivities.Columns.Add("ActivityType");
            dtactivities.Columns.Add("ActivityTypeImage");
            dtactivities.Columns.Add("ActivityTimeImage");
            dtactivities.Columns.Add("ProspectHostEventLink");
            dtactivities.Columns.Add("ActivityLink");
            dtactivities.Columns.Add("IsHost", typeof(Boolean));
            dtactivities.Columns.Add("EventId", typeof(Int64));
            dtactivities.Columns.Add("EventName");
            dtactivities.Columns.Add("ActivityText");
            dtactivities.Columns.Add("ContactWith");
            dtactivities.Columns.Add("EventStatus");
            dtactivities.Columns.Add("DeleteActivityLink");
            dtactivities.Columns.Add("ActivityStatus", typeof(bool));
            // added event status

            if (todayActivity != null)
            {
                for (int icount = 0; icount < todayActivity.Count; icount++)
                {
                    string timeimage      = "";
                    string activitytime   = "";
                    string activitytext   = "";
                    string withtext       = string.Empty;
                    string strEventStatus = string.Empty;

                    string editlink = "javascript:alert('Link not available');";

                    if (todayActivity[icount].EventId > 0)
                    {
                        editlink     = "/App/Common/EventDetails.aspx?Tab=Activities&EventID=" + todayActivity[icount].EventId.ToString();
                        activitytext = "Event";
                    }
                    else if (todayActivity[icount].IsHost)
                    {
                        editlink     = "/App/Franchisee/SalesRep/SalesRepProspectDetails.aspx?Type=Host&MyActivity=True&ProspectID=" + todayActivity[icount].ProspectID;
                        activitytext = "Host";
                    }
                    else
                    {
                        editlink     = "/App/Franchisee/SalesRep/SalesRepProspectDetails.aspx?Type=Prospect&MyActivity=True&ProspectID=" + todayActivity[icount].ProspectID;
                        activitytext = "Prospect";
                    }

                    string activitylink = "javascript:alert('Link not available');";
                    string deletelink   = "javascript:alert('Link not available');";

                    if (todayActivity[icount].ActivityTime != null && todayActivity[icount].ActivityTime.Trim().Length > 0)
                    {
                        if (Convert.ToDateTime(todayActivity[icount].ActivityTime).ToString("MM/dd/yyyy").Equals(todayActivity[icount].ActivityTime.Trim()))
                        {
                            activitytime = Convert.ToDateTime(todayActivity[icount].ActivityTime).ToString("MMMM dd, yyyy");
                            todayActivity[icount].ActivityTime = Convert.ToDateTime(todayActivity[icount].ActivityTime).ToString("MM/dd/yyyy") + " 11:30 PM";
                        }

                        else
                        {
                            activitytime = Convert.ToDateTime(todayActivity[icount].ActivityTime).ToString("MMMM dd, yyyy @ hh:mm tt");
                        }

                        if (DateTime.Now.Date == Convert.ToDateTime(todayActivity[icount].ActivityTime).Date)
                        {
                            if (DateTime.Now.TimeOfDay.CompareTo(Convert.ToDateTime(todayActivity[icount].ActivityTime).TimeOfDay) == 1)
                            {
                                timeimage = "<img src='/App/Images/red-flag.gif' alt='' title = 'Past Activity' />";
                            }
                            else
                            {
                                timeimage = "<img src='/App/Images/orng-flag.gif' alt='' title = \"Today's Activity\" />";
                            }
                        }
                        else if (DateTime.Now < Convert.ToDateTime(todayActivity[icount].ActivityTime).Date)
                        {
                            timeimage = "<img src='/App/Images/green-flag.gif' alt='' title = 'Future Activity' />";
                        }
                        else
                        {
                            timeimage = "<img src='/App/Images/red-flag.gif' alt='' title = 'Past Activity' />";
                        }
                    }

                    string typeimage = "<img src='/App/Images/red-box-ma.gif' alt='' />";

                    if (todayActivity[icount].ActivityType == "Task")
                    {
                        activitylink = "/App/Franchisor/AddTask.aspx?TaskID=" + todayActivity[icount].ActivityID + "&Parent=Activity"; typeimage = "<img src='/App/Images/icon-task.gif' alt='Task' title='Task' />";
                    }
                    if (todayActivity[icount].ActivityType == "Call")
                    {
                        activitylink = "/App/Franchisor/AddCallProspect.aspx?ContactCallID=" + todayActivity[icount].ActivityID + "&Parent=Activity"; typeimage = "<img src='/App/Images/icon-call.gif' alt='Call' title='Call' />";
                    }
                    if (todayActivity[icount].ActivityType == "Meeting")
                    {
                        activitylink = "/App/Franchisor/AddMeeting.aspx?ContactMeetingID=" + todayActivity[icount].ActivityID + "&Parent=Activity"; typeimage = "<img src='/App/Images/icon-meeting.gif' alt='Meeting' title='Meeting' />";
                    }

                    deletelink = "javascript:DeleteActivity('" + todayActivity[icount].ActivityType + "'," +
                                 todayActivity[icount].ActivityID + ",'" + todayActivity[icount].ActivityMarkedStatus + "');";

                    if (todayActivity[icount].EventId > 0)
                    {
                        todayActivity[icount].Prospect = todayActivity[icount].EventName;
                        strEventStatus = "<br>Event Status:" + Convert.ToString(Enum.Parse(typeof(EventStatus), todayActivity[icount].EventStatus.ToString()));
                    }
                    if (todayActivity[icount].ContactID > 0)
                    {
                        withtext = "With";
                    }


                    dtactivities.Rows.Add(new object[]
                    {
                        todayActivity[icount].ActivityID,
                        todayActivity[icount].ContactID,
                        todayActivity[icount].ProspectID,
                        todayActivity[icount].ProspectContactID,
                        todayActivity[icount].Prospect,
                        todayActivity[icount].ContactName,
                        todayActivity[icount].Subject, activitytime,
                        todayActivity[icount].ActivityType, typeimage, timeimage,
                        editlink, activitylink, todayActivity[icount].IsHost,
                        todayActivity[icount].EventId,
                        todayActivity[icount].EventName, activitytext, withtext,
                        strEventStatus, deletelink, todayActivity[icount].ActivityMarkedStatus
                    });
                }
            }
            if (todayActivity != null && todayActivity.Count > 0)
            {
                if (todayActivity.Count > 10)
                {
                    todayActivityDiv.Style.Add(HtmlTextWriterStyle.OverflowY, "auto");
                    todayActivityDiv.Style.Add(HtmlTextWriterStyle.OverflowX, "hidden");
                    todayActivityDiv.Style.Add(HtmlTextWriterStyle.Height, "300px");
                }
                todayactivities.DataSource = dtactivities;
                todayactivities.DataBind();
                _noRecordFoundTodayActivity.Style.Add(HtmlTextWriterStyle.Display, "none");
            }
            else
            {
                todayActivityMessage.ShowErrorMessage("No activity scheduled for today.");
                _noRecordFoundTodayActivity.Style.Add(HtmlTextWriterStyle.Display, "block");
            }
        }