protected void RCBStudentsSearch_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            string searchtext = string.Empty;

            searchtext = e.Text;
            try
            {
                DataTable SwitchToStudetndt = new DataTable();
                string    StudentNo = string.Empty, LeadId = string.Empty;
                StudentNo = Convert.ToString(Session["StudentNo"]);
                LeadId    = Convert.ToString(Session["leadID"]);
                if (StudentNo != string.Empty && StudentNo != "0")
                {
                    RCBStudentsSearch.DataSource = DyDataAccessManager.GetStudentMobileNo(searchtext);
                }
                else if (LeadId != string.Empty && LeadId != "0")
                {
                    RCBStudentsSearch.DataSource = DyDataAccessManager.GetLeadMobileNo(searchtext);
                }
                RCBStudentsSearch.DataTextField  = "FullName";
                RCBStudentsSearch.DataValueField = "MobilePhone";
                RCBStudentsSearch.DataBind();
            }
            catch (Exception ex)
            {
            }
        }
 // bind textbox composeemail in student   id and department
 private void StudentDetailBind()
 {
     try
     {
         string StudentNo = string.Empty, LeadId = string.Empty;
         StudentNo = Convert.ToString(Session["StudentNo"]);
         DataTable dtStudentEmail = new DataTable();
         dtStudentEmail = DyDataAccessManager.GetStudentEmail(StudentNo);
         if (dtStudentEmail.Rows.Count > 0)
         {
             if (dtStudentEmail.Rows[0]["Email"].ToString() != string.Empty && dtStudentEmail.Rows[0]["Email2"].ToString() != string.Empty)
             {
                 Rtxtemailto.Text = dtStudentEmail.Rows[0]["Email"].ToString() + ',' + dtStudentEmail.Rows[0]["Email2"].ToString();
             }
             if (dtStudentEmail.Rows[0]["Email"].ToString() == string.Empty)
             {
                 Rtxtemailto.Text = dtStudentEmail.Rows[0]["Email2"].ToString();
             }
             if (dtStudentEmail.Rows[0]["Email2"].ToString() == string.Empty)
             {
                 Rtxtemailto.Text = dtStudentEmail.Rows[0]["Email"].ToString();
             }
         }
         else
         {
             // tabstudentlead.Text = "No Available";
         }
     }
     catch (Exception ex)
     {
     }
 }
Example #3
0
 //=============================================================================================================
 // bind textbox composeemail in student   id and department
 private void StudentDetailBind()
 {
     try
     {
         string StudentNo = string.Empty, LeadId = string.Empty;
         StudentNo = Convert.ToString(Session["StudentNo"]);
         LeadId    = Convert.ToString(Session["leadID"]);
         DataTable dtStudentEmail = new DataTable();
         dtStudentEmail = DyDataAccessManager.GetStudentEmail(StudentNo);
         if (dtStudentEmail.Rows.Count > 0)
         {
             RtxtMobile.Text = Convert.ToString(dtStudentEmail.Rows[0]["MobilePhone"]);
         }
     }
     catch (Exception ex)
     {
     }
 }
 // bind textbox composeemail in Lead   id and department
 private void LeadDetailBind()
 {
     try
     {
         string StudentNo = string.Empty, LeadId = string.Empty;
         StudentNo = Convert.ToString(Session["StudentNo"]);
         LeadId    = Convert.ToString(Session["leadID"]);
         DataTable dtStudentEmail = new DataTable();
         dtStudentEmail = DyDataAccessManager.GetLeadEmail(LeadId);
         if (dtStudentEmail.Rows.Count > 0)
         {
             lblStdLeadName.Text      = "<b>Lead:- </b>" + Convert.ToString(dtStudentEmail.Rows[0]["Name"]);
             LBselectstudentLead.Text = "<b>Lead:- </b>" + Convert.ToString(dtStudentEmail.Rows[0]["Name"]);
         }
         else
         {
             lblStdLeadName.Text      = "<b>Lead:- </b>" + "No Available";
             LBselectstudentLead.Text = "<b>Lead:- </b>" + "No Available";
         }
     }
     catch (Exception ex)
     {
     }
 }
Example #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Session.Clear();
                string ApplaunchURL = string.Empty;
                ApplaunchURL            = HttpContext.Current.Request.Url.AbsoluteUri;
                Session["ApplaunchURL"] = ApplaunchURL;
                if (Request.QueryString["Campus"] != null && Request.QueryString["Campus"] != string.Empty)
                {
                    DataTable dtConfig = DataAccessManager.GetConfigration(Convert.ToString(Request.QueryString["Campus"]));
                    if (dtConfig.Rows.Count > 0)
                    {
                        Session["GlobalValueKey"] = dtConfig.Rows[0]["CampusConStr"].ToString();
                        Session["CampusID"]       = dtConfig.Rows[0]["CampusID"].ToString();
                        Session["Campuslogo"]     = dtConfig.Rows[0]["Clientlogo"].ToString();
                        Session["CampusName"]     = Convert.ToString(Request.QueryString["Campus"]);
                    }
                    else
                    {
                        Session["GlobalValueKey"] = string.Empty;
                        Session["CampusID"]       = string.Empty;
                        Session["globalERROR"]    = "Some query string are missing or wrong! Check with your network administrator";
                        Response.Redirect("~/Error.aspx");
                    }
                }
                else
                {
                    Session["globalERROR"] = "Campus Code Null";
                    Response.Redirect("~/Error.aspx");
                }
                if (Request.QueryString["StudentNo"] != null && Request.QueryString["StudentNo"] != string.Empty && Request.QueryString["StudentNo"] != "0")
                {
                    DataTable dtCheckValueStudent = DyDataAccessManager.QueryStringValueCheck("dbo.Students", "studentNo", Request.QueryString["StudentNo"]);
                    if (dtCheckValueStudent.Rows.Count == 0)
                    {
                        Session["globalERROR"] = "Student No is not exist!";
                        Response.Redirect("~/Error.aspx");
                    }
                    Session["StudentNo"] = Convert.ToString(Request.QueryString["StudentNo"]);
                }

                if (Request.QueryString["LeadId"] != null && Request.QueryString["LeadId"] != string.Empty && Request.QueryString["LeadId"] != "0")

                {
                    DataTable dtCheckValueLead = DyDataAccessManager.QueryStringValueCheck("dbo.Lead", "LeadsID", Request.QueryString["LeadId"]);
                    if (dtCheckValueLead.Rows.Count == 0)
                    {
                        Session["globalERROR"] = "LeadsId is not exist!";
                        Response.Redirect("~/Error.aspx");
                    }
                    Session["LeadId"] = Convert.ToString(Request.QueryString["LeadId"]);
                }

                if (Session["LeadId"] == "" && Session["StudentNo"] == "")
                {
                    Session["globalERROR"] = "Student No and Lead Id   Null";
                    Response.Redirect("~/Error.aspx");
                }

                if (Session["LeadId"] == "0" && Session["StudentNo"] == "0")
                {
                    Session["globalERROR"] = "Student No and Lead Id   Null";
                    Response.Redirect("~/Error.aspx");
                }
                if (Request.QueryString["DeptID"] != null && Request.QueryString["DeptID"] != string.Empty && Request.QueryString["DeptID"] != "0")
                {
                    DataTable dtCheckValueDeptId = DyDataAccessManager.QueryStringValueCheck("dbo.Departments", "deptid", Request.QueryString["DeptID"]);
                    if (dtCheckValueDeptId.Rows.Count == 0)
                    {
                        Session["globalERROR"] = "Department ID is not exist!";
                        Response.Redirect("~/Error.aspx");
                    }
                    Session["DeptID"] = Convert.ToString(Request.QueryString["DeptID"]);
                }
                else
                {
                    Session["globalERROR"] = "Deptment Id  is  Null";
                    Response.Redirect("~/Error.aspx");
                }

                string Starturl = string.Empty;

                Starturl = "~/frmlogin.aspx";


                Response.Redirect(Starturl, false);
                Context.ApplicationInstance.CompleteRequest();
            }
            catch (Exception ex)
            {
                throw ex; //
            }
        }
Example #6
0
        //private void DepartSent_SMS()
        //{
        //    DataTable dtDepartmentSMSSent = new DataTable();
        //    dtDepartmentSMSSent = DataAccessManager.GetSMSSent( Convert.ToString(Session["DeptID"]), Convert.ToInt32(Session["CampusID"]));
        //    Session["dtDepartmentSMSSent"] = dtDepartmentSMSSent;
        //    rgvDepartmentSent.DataSource = (DataTable)Session["dtDepartmentSMSSent"];
        //}
        //protected void rgvDepartmentSent_SortCommand(object sender, GridSortCommandEventArgs e)
        //{
        //    this.rgvDepartmentSent.MasterTableView.AllowNaturalSort = true;
        //    this.rgvDepartmentSent.MasterTableView.Rebind();
        //}

        //protected void rgvDepartmentSent_PageIndexChanged(object sender, GridPageChangedEventArgs e)
        //{
        //    try
        //    {
        //        rgvDepartmentSent.DataSource = (DataTable)Session["dtDepartmentSMSSent"];
        //    }
        //    catch (Exception ex)
        //    {

        //    }
        //}
        #endregion
        public void fetchmail(string DeptID, int CampusID)
        {
            try
            {
                DataTable dtEmailConfig = DataAccessManager.GetEmailConfigDetail(DeptID, CampusID);
                if (dtEmailConfig.Rows.Count > 0)
                {
                    Pop3Client pop3Client;
                    pop3Client = new Pop3Client();
                    pop3Client.Connect(dtEmailConfig.Rows[0]["Pop3"].ToString(), Convert.ToInt32(dtEmailConfig.Rows[0]["PortIn"]), Convert.ToBoolean(dtEmailConfig.Rows[0]["SSL"]));
                    pop3Client.Authenticate(dtEmailConfig.Rows[0]["DeptEmail"].ToString(), dtEmailConfig.Rows[0]["Pass"].ToString(), AuthenticationMethod.UsernameAndPassword);
                    if (pop3Client.Connected)
                    {
                        int count = pop3Client.GetMessageCount();
                        int progressstepno;
                        if (count == 0)
                        {
                        }
                        else
                        {
                            progressstepno = 100 - count;
                            this.Emails    = new List <Email>();
                            for (int i = 1; i <= count; i++)
                            {
                                OpenPop.Mime.Message message = pop3Client.GetMessage(i);
                                Email email = new Email()
                                {
                                    MessageNumber = i,
                                    messageId     = message.Headers.MessageId,
                                    Subject       = message.Headers.Subject,
                                    DateSent      = message.Headers.DateSent,
                                    From          = message.Headers.From.Address
                                };
                                MessagePart body = message.FindFirstHtmlVersion();
                                if (body != null)
                                {
                                    email.Body = body.GetBodyAsText();
                                }
                                else
                                {
                                    body = message.FindFirstHtmlVersion();
                                    if (body != null)
                                    {
                                        email.Body = body.GetBodyAsText();
                                    }
                                }
                                email.IsAttached = false;
                                this.Emails.Add(email);
                                //Attachment Process
                                List <MessagePart> attachments = message.FindAllAttachments();
                                foreach (MessagePart attachment in attachments)
                                {
                                    email.IsAttached = true;
                                    string FolderName = string.Empty;
                                    FolderName = Convert.ToString(Session["CampusName"]);
                                    String path = Server.MapPath("~/InboxAttachment/" + FolderName);
                                    if (!Directory.Exists(path))
                                    {
                                        // Try to create the directory.
                                        DirectoryInfo di = Directory.CreateDirectory(path);
                                    }
                                    string ext = attachment.FileName.Split('.')[1];
                                    // FileInfo file = new FileInfo(Server.MapPath("InboxAttachment\\") + attachment.FileName.ToString());
                                    FileInfo file = new FileInfo(Server.MapPath("InboxAttachment\\" + FolderName + "\\") + attachment.FileName.ToString());
                                    attachment.SaveToFile(file);
                                    Attachment att = new Attachment();
                                    att.messageId = message.Headers.MessageId;
                                    att.FileName  = attachment.FileName;
                                    attItem.Add(att);
                                }
                                //System.Threading.Thread.Sleep(500);
                            }

                            //Insert into database Inbox table
                            DataTable dtStudentNo   = new DataTable();
                            bool      IsReadAndSave = false;
                            foreach (var ReadItem in Emails)
                            {
                                string from = string.Empty, subj = string.Empty, messId = string.Empty, Ebody = string.Empty;
                                from   = Convert.ToString(ReadItem.From);
                                subj   = Convert.ToString(ReadItem.Subject);
                                messId = Convert.ToString(ReadItem.messageId);
                                Ebody  = Convert.ToString(ReadItem.Body);
                                if (Ebody != string.Empty && Ebody != null)
                                {
                                    Ebody = Ebody.Replace("'", " ");
                                }

                                DateTime date   = ReadItem.DateSent;
                                bool     IsAtta = ReadItem.IsAttached;
                                //Student Email

                                if (Source.SOrL(Convert.ToString(Session["StudentNo"]), Convert.ToString(Session["leadID"])))
                                {
                                    dtStudentNo = DyDataAccessManager.GetStudentNo(from, from);

                                    if (dtStudentNo.Rows.Count == 0)
                                    {
                                        IsReadAndSave = DataAccessManager.ReadEmailAndSaveDatabase("0", Convert.ToString(Session["DeptID"]), messId, dtEmailConfig.Rows[0]["DeptEmail"].ToString(),
                                                                                                   from, subj, Ebody, IsAtta, date, Convert.ToInt32(Session["CampusID"]));
                                    }
                                    else
                                    {
                                        IsReadAndSave = DataAccessManager.ReadEmailAndSaveDatabase(dtStudentNo.Rows[0]["StudentNo"].ToString(),
                                                                                                   Convert.ToString(Session["DeptID"]), messId, dtEmailConfig.Rows[0]["DeptEmail"].ToString(), from, subj, Ebody, IsAtta, date, Convert.ToInt32(Session["CampusID"]));
                                    }
                                }
                                //Leads Email
                                if (Source.SOrL(Convert.ToString(Session["ParamStudentNo"]), Convert.ToString(Session["ParamleadID"])) == false)
                                {
                                    dtStudentNo = DyDataAccessManager.GetLeadsID(from, from);

                                    if (dtStudentNo.Rows.Count == 0)
                                    {
                                        IsReadAndSave = DataAccessManager.ReadEmailAndSaveDatabaseLead("0", Convert.ToString(Session["DeptID"]), messId,
                                                                                                       dtEmailConfig.Rows[0]["DeptEmail"].ToString(), from, subj, Ebody, IsAtta, date, Convert.ToInt32(Session["CampusID"]));
                                    }
                                    else
                                    {
                                        IsReadAndSave = DataAccessManager.ReadEmailAndSaveDatabaseLead(dtStudentNo.Rows[0]["LeadsID"].ToString(),
                                                                                                       Convert.ToString(Session["DeptID"]), messId, dtEmailConfig.Rows[0]["DeptEmail"].ToString(), from, subj, Ebody, IsAtta, date, Convert.ToInt32(Session["CampusID"]));
                                    }
                                }
                                //
                            }
                            //Insert into database Attachment table
                            foreach (var attachItem in attItem)
                            {
                                bool   success;
                                string Filname = attachItem.FileName;
                                string MssID   = attachItem.messageId;
                                success = DataAccessManager.ReadEmailAttachmentAndSaveDatabase(MssID, Filname);
                            }
                            Emails.Clear();
                            // attItem.Clear();
                            pop3Client.DeleteAllMessages();
                            //StartNotification(count);
                        }
                    }

                    pop3Client.Disconnect();
                }
            }
            catch (Exception ex)
            {
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            RALPSwitchtoanthoruser.Visible = true;
            if (Session["pagename"] != null)
            {
                lbpagename.Text     = Convert.ToString(Session["pagename"]);
                lbpagename.CssClass = "additionalColumn";
            }
            if (!IsPostBack)
            {
                LBloginuser.Text = "<b>Current User:- </b>" + Convert.ToString(Session["username"]);



                #region Campus Logo
                imgCampusLogo.ImageUrl = "~/Content/clientlogo/" + Convert.ToString(Session["Campuslogo"]);
                #endregion

                if (Session["CampusID"] != null)
                {
                    RCBStudentsLeadSearch.Enabled  = true;
                    RBSelectStudent.Enabled        = true;
                    RBSelectLead.Enabled           = true;
                    RbtnRefreshApplication.Enabled = true;
                    #region "For all User Menu Bind"
                    string username = string.Empty, user_level = string.Empty;
                    username   = Convert.ToString(Session["username"]);
                    user_level = Convert.ToString(Session["user_level"]);

                    Menudt = DataAccessManager.UserMenuBind(user_level);
                    if (Menudt.Rows.Count > 0)
                    {
                        List <SiteDataItem> siteData = new List <SiteDataItem>();

                        DataRow[] MenuparentRow = Menudt.Select("ParentID='0'");


                        foreach (DataRow l_parentRow in MenuparentRow)
                        {
                            string text = string.Empty, url = string.Empty, id = string.Empty, parentId = string.Empty, MobileView = string.Empty;

                            text       = Convert.ToString(l_parentRow["Menu"]);
                            id         = Convert.ToString(l_parentRow["Menu_ID"]);
                            url        = Convert.ToString(l_parentRow["link"]);
                            parentId   = Convert.ToString(l_parentRow["parentId"]);
                            MobileView = Convert.ToString(l_parentRow["MobileView"]);
                            if (MobileView == "1")
                            {
                                MobileView = "additionalColumn";
                            }
                            else
                            {
                                MobileView = string.Empty;
                            }
                            if (parentId == "0")
                            {
                                siteData.Add(new SiteDataItem(Convert.ToInt32(id), null, text, url, MobileView));
                            }
                            else
                            {
                                siteData.Add(new SiteDataItem(Convert.ToInt32(id), Convert.ToInt32(parentId), text, url, MobileView));
                            }


                            DataRow[] MenuChildRow = Menudt.Select("ParentID='" + id + "' ");
                            if (MenuChildRow.Length > 0)
                            {
                                foreach (DataRow l_ChildRow in MenuChildRow)
                                {
                                    text       = string.Empty;
                                    url        = string.Empty;
                                    id         = string.Empty;
                                    parentId   = string.Empty;
                                    MobileView = string.Empty;
                                    text       = Convert.ToString(l_ChildRow["Menu"]);
                                    id         = Convert.ToString(l_ChildRow["Menu_ID"]);
                                    url        = Convert.ToString(l_ChildRow["link"]);
                                    parentId   = Convert.ToString(l_ChildRow["parentId"]);
                                    MobileView = Convert.ToString(l_ChildRow["MobileView"]);
                                    if (MobileView == "1")
                                    {
                                        MobileView = "additionalColumn";
                                    }
                                    else
                                    {
                                        MobileView = string.Empty;
                                    }
                                    if (parentId == "0")
                                    {
                                        siteData.Add(new SiteDataItem(Convert.ToInt32(id), null, text, url, MobileView));
                                    }
                                    else
                                    {
                                        siteData.Add(new SiteDataItem(Convert.ToInt32(id), Convert.ToInt32(parentId), text, url, MobileView));
                                    }
                                }
                            }
                        }
                        Session["menudata"] = siteData;
                        if (Session["menudata"] != null)
                        {
                            RMenuMain.DataTextField        = "Text";
                            RMenuMain.DataNavigateUrlField = "Url";
                            RMenuMain.DataFieldID          = "ID";
                            RMenuMain.DataValueField       = "ID";
                            RMenuMain.DataFieldParentID    = "ParentID";
                            RMenuMain.DataSource           = (List <SiteDataItem>)Session["menudata"];
                            RMenuMain.DataBind();
                        }


                        foreach (RadMenuItem item in RMenuMain.GetAllItems())
                        {
                            string text = item.Text;
                            string id   = Convert.ToString(item.Value);

                            DataRow[] MenuItemRow = Menudt.Select(" Menu_ID= '" + id + "' And MobileView=1");
                            if (MenuItemRow.Length > 0)
                            {
                                item.CssClass = "additionalColumn";
                            }



                            //
                        }
                    }
                    # endregion
                }
                if (Session["CampusID"] == null || Session["user_level"] == "99")
                {
                    RCBStudentsLeadSearch.Enabled  = false;
                    RBSelectStudent.Enabled        = false;
                    RBSelectLead.Enabled           = false;
                    RbtnRefreshApplication.Enabled = false;
                    #region "Menu Bind without Process by Admin"
                    string username = string.Empty, user_level = string.Empty;
                    username   = Convert.ToString(Session["username"]);
                    user_level = Convert.ToString(Session["user_level"]);

                    Menudt = DataAccessManager.UserMenuBind(user_level, "1");
                    if (Menudt.Rows.Count > 0)
                    {
                        List <SiteDataItem> siteData = new List <SiteDataItem>();

                        DataRow[] MenuparentRow = Menudt.Select("ParentID='0'");


                        foreach (DataRow l_parentRow in MenuparentRow)
                        {
                            string text = string.Empty, url = string.Empty, id = string.Empty, parentId = string.Empty, MobileView = string.Empty;

                            text       = Convert.ToString(l_parentRow["Menu"]);
                            id         = Convert.ToString(l_parentRow["Menu_ID"]);
                            url        = Convert.ToString(l_parentRow["link"]);
                            parentId   = Convert.ToString(l_parentRow["parentId"]);
                            MobileView = Convert.ToString(l_parentRow["MobileView"]);
                            if (MobileView == "1")
                            {
                                MobileView = "additionalColumn";
                            }
                            else
                            {
                                MobileView = string.Empty;
                            }
                            if (parentId == "0")
                            {
                                siteData.Add(new SiteDataItem(Convert.ToInt32(id), null, text, url, MobileView));
                            }
                            else
                            {
                                siteData.Add(new SiteDataItem(Convert.ToInt32(id), Convert.ToInt32(parentId), text, url, MobileView));
                            }


                            DataRow[] MenuChildRow = Menudt.Select("ParentID='" + id + "' ");
                            if (MenuChildRow.Length > 0)
                            {
                                foreach (DataRow l_ChildRow in MenuChildRow)
                                {
                                    text       = string.Empty;
                                    url        = string.Empty;
                                    id         = string.Empty;
                                    parentId   = string.Empty;
                                    MobileView = string.Empty;
                                    text       = Convert.ToString(l_ChildRow["Menu"]);
                                    id         = Convert.ToString(l_ChildRow["Menu_ID"]);
                                    url        = Convert.ToString(l_ChildRow["link"]);
                                    parentId   = Convert.ToString(l_ChildRow["parentId"]);
                                    MobileView = Convert.ToString(l_ChildRow["MobileView"]);
                                    if (MobileView == "1")
                                    {
                                        MobileView = "additionalColumn";
                                    }
                                    else
                                    {
                                        MobileView = string.Empty;
                                    }
                                    if (parentId == "0")
                                    {
                                        siteData.Add(new SiteDataItem(Convert.ToInt32(id), null, text, url, MobileView));
                                    }
                                    else
                                    {
                                        siteData.Add(new SiteDataItem(Convert.ToInt32(id), Convert.ToInt32(parentId), text, url, MobileView));
                                    }
                                }
                            }
                        }
                        Session["menudata"] = siteData;
                        if (Session["menudata"] != null)
                        {
                            RMenuMain.DataTextField        = "Text";
                            RMenuMain.DataNavigateUrlField = "Url";
                            RMenuMain.DataFieldID          = "ID";
                            RMenuMain.DataValueField       = "ID";
                            RMenuMain.DataFieldParentID    = "ParentID";
                            RMenuMain.DataSource           = (List <SiteDataItem>)Session["menudata"];
                            RMenuMain.DataBind();
                        }


                        foreach (RadMenuItem item in RMenuMain.GetAllItems())
                        {
                            string text = item.Text;
                            string id   = Convert.ToString(item.Value);

                            DataRow[] MenuItemRow = Menudt.Select(" Menu_ID= '" + id + "' And MobileView=1");
                            if (MenuItemRow.Length > 0)
                            {
                                item.CssClass = "additionalColumn";
                            }



                            //
                        }
                    }
                    # endregion
                }
                #region "Search Control"

                string SearchControlLeadId = string.Empty, SearchControlStudentNo = string.Empty;
                SearchControlLeadId    = Convert.ToString(Session["LeadId"]);
                SearchControlStudentNo = Convert.ToString(Session["StudentNo"]);
                if (SearchControlLeadId != string.Empty && SearchControlLeadId != null && SearchControlLeadId != "0")
                {
                    #region "Search Control Lead Setting"
                    RCBStudentsLeadSearch.WebServiceSettings.Method = "GetLeads";
                    RCBStudentsLeadSearch.HeaderTemplate            = new LeadHeaderTemplate();
                    RCBStudentsLeadSearch.Width         = 267;
                    RCBStudentsLeadSearch.DropDownWidth = 880;
                    RCBStudentsLeadSearch.EmptyMessage  = "Select a Lead";
                    RBSelectLead.Checked = true;
                    #endregion
                }
                if (SearchControlStudentNo != string.Empty && SearchControlStudentNo != null && SearchControlStudentNo != "0")
                {
                    #region "Search Control Student Setting"
                    RCBStudentsLeadSearch.WebServiceSettings.Method = "GetStudents";
                    RCBStudentsLeadSearch.HeaderTemplate            = new StudentHeaderTemplate();
                    RCBStudentsLeadSearch.Width         = 280;
                    RCBStudentsLeadSearch.DropDownWidth = 500;
                    RCBStudentsLeadSearch.EmptyMessage  = "Select a Student";
                    RBSelectStudent.Checked             = true;
                    #endregion
                }
                #endregion

                #region "departmentnamebind"

                /* Swtich Department */

                /* DataTable dtdept = DyDataAccessManager.GetListDepartment(DeptID);
                 * if (dtdept.Rows.Count > 0)
                 * {
                 *   LBDepartment.Text = "<b>Department:- </b>" + Convert.ToString(dtdept.Rows[0]["DeptDescription"]);
                 *
                 * }
                 * else
                 * {
                 *   LBDepartment.Text = "<b>Department:- </b>" + "Not Available";
                 * }*/

                int DeptID = 0;
                DeptID = Convert.ToInt32(Session["DeptID"]);
                DataTable dtDepartment = new DataTable();
                dtDepartment            = DyDataAccessManager.GetListDepartmentforswitch();
                RddlDept.DataSource     = dtDepartment;
                RddlDept.DataTextField  = "DeptDescription";
                RddlDept.DataValueField = "DeptID";
                RddlDept.DataBind();
                //RddlDept.Items[0].Text = "Select Departments";
                //RddlDept.SelectedIndex = 0;

                RddlDept.SelectedValue = Convert.ToString(DeptID);
                RddlDept.Enabled       = false;
                if (Convert.ToInt32(Session["AllowSwitchdept"]) == 1)
                {
                    RddlDept.Enabled = true;
                }
                #endregion
                #region "SMS Count"
                CountSMS();
                #endregion
            }
            string LeadId = string.Empty, StudentNo = string.Empty;
            LeadId    = Convert.ToString(Session["LeadId"]);
            StudentNo = Convert.ToString(Session["StudentNo"]);
            string type = string.Empty;
            if (StudentNo != string.Empty && StudentNo != null && StudentNo != "0")
            {
                StudentDetailBind();
            }
            if (LeadId != string.Empty && LeadId != null && LeadId != "0")
            {
                LeadDetailBind();
            }
        }
Example #8
0
        protected void btnSMSSend_Click(object sender, EventArgs e)
        {
            try
            {
                #region "Start"
                if (Page.IsValid)
                {
                    LRlblSmSResult.Visible = true;
                    string SMSLongCode = string.Empty, Mobile = string.Empty, Message = string.Empty, CampusID = string.Empty,
                           StudentNo = string.Empty, LeadNo = string.Empty, DeptId = string.Empty, isdcode = string.Empty;
                    lblSmSResult.Text = string.Empty;
                    CampusID          = Convert.ToString(Session["CampusID"]);
                    StudentNo         = Convert.ToString(Session["StudentNo"]);
                    LeadNo            = Convert.ToString(Session["leadID"]);
                    DeptId            = Convert.ToString(Session["DeptID"]);

                    if (StudentNo == string.Empty)
                    {
                        StudentNo = "0";
                    }
                    if (LeadNo == string.Empty)
                    {
                        LeadNo = "0";
                    }

                    SMSLongCode = Convert.ToString(RddlSMSLongCode.SelectedText);
                    isdcode     = Convert.ToString(RtxtIscode.Text);
                    Mobile      = isdcode + Convert.ToString(RtxtMobile.Text);
                    Message     = Convert.ToString(REMessageSMSEditor.Text);

                    Boolean mobilechk = true;
                    if (StudentNo != "0")
                    {
                        mobilechk = DyDataAccessManager.CheckStdMobleSMS(Mobile);
                    }
                    if (LeadNo != "0")
                    {
                        mobilechk = DyDataAccessManager.CheckStdMobleSMS(Mobile);
                    }

                    string SMSLongCodeId = string.Empty;
                    SMSLongCodeId = Convert.ToString(RddlSMSLongCode.SelectedValue);
                    DataTable dtSMSSetup = DataAccessManager.GetSMSLongCodeFullList(Convert.ToString(Session["CampusID"]), SMSLongCodeId);
                    if (dtSMSSetup.Rows.Count > 0)
                    {
                        try
                        {
                            var twilio  = new Twilio.TwilioRestClient(dtSMSSetup.Rows[0]["AccountSID"].ToString(), dtSMSSetup.Rows[0]["AuthToken"].ToString());
                            var message = twilio.SendMessage(SMSLongCode, Mobile, Message);
                            if (message != null)
                            {
                                if (message.Sid != null)
                                {
                                    try
                                    {
                                        var     twilioGet = new Twilio.TwilioRestClient(dtSMSSetup.Rows[0]["AccountSID"].ToString(), dtSMSSetup.Rows[0]["AuthToken"].ToString());
                                        var     msg       = twilioGet.GetMessage(message.Sid);
                                        Boolean result    = DataAccessManager.ReadSMSAndSaveDatabase(msg.AccountSid, msg.DateSent.ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToString(msg.Sid), Convert.ToString(msg.To), Convert.ToString(msg.From), Convert.ToString(msg.Body), Convert.ToString(msg.Status), Convert.ToString(msg.Direction), Convert.ToString(msg.ErrorCode), Convert.ToString(msg.ErrorMessage), msg.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"), msg.DateUpdated.ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToString(StudentNo), Convert.ToString(LeadNo), Convert.ToString(DeptId));
                                        if (result == true)
                                        {
                                            lblSmSResult.Text             = "Message has been sent!";
                                            RddlSMSLongCode.SelectedIndex = 0;
                                            if (Convert.ToInt32(ViewState["STDcount"]) == 2)
                                            {
                                                RddlSMSLongCode.SelectedIndex = 1;
                                            }
                                            RtxtIscode.Text         = "+1";
                                            RtxtMobile.Text         = string.Empty;
                                            REMessageSMSEditor.Text = string.Empty;
                                            SMSLongCodeBind();
                                            BindSMSTemplate();
                                            StudentDetailBind();
                                            LeadDetailBind();
                                            /*27 july change After SMS Message send, return to SMS page*/
                                            /*Start*/
                                            string LeadId = string.Empty;
                                            LeadId    = Convert.ToString(Session["LeadId"]);
                                            StudentNo = Convert.ToString(Session["StudentNo"]);

                                            string type = string.Empty;
                                            if (StudentNo != string.Empty && StudentNo != null && StudentNo != "0")
                                            {
                                                type = "Student";
                                            }
                                            if (LeadId != string.Empty && LeadId != null && LeadId != "0")
                                            {
                                                type = "Lead";
                                            }

                                            Session["PageClick"] = "0";
                                            Response.Redirect("frmstudentlead.aspx?type=" + type + "&Operation=Receive SMS");
                                            /*End*/
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        btnSMSSend.Enabled = true;
                                        lblSmSResult.Text  = "Message Failed!";
                                    }
                                }
                                else
                                {
                                    lblSmSResult.Text = "Message failed,Please check the number.";
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            btnSMSSend.Enabled = true;
                            lblSmSResult.Text  = "Message Failed!";
                        }
                    }

                    else
                    {
                        btnSMSSend.Enabled = true;
                        lblSmSResult.Text  = "Please make sure update SMS Configration!.";
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
        }