Beispiel #1
0
    protected void BindSearchFieldDdl()
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        DataTable table = new DataTable();

        table.Columns.Add("Text");
        table.Columns.Add("Value");
        DataRow       dr;
        List <string> lst = new List <string> {
            "None / All", "Policy No.", "Claim No.", "Mobile Number", "Date",
        };

        if (CurrentUser.Role() == "Admin")
        {
            lst.Add("Sent By");
        }
        foreach (var x in lst)
        {
            dr          = table.NewRow();
            dr["Value"] = x;
            dr["Text"]  = x;
            table.Rows.Add(dr);
        }
        ddlSearchField.DataSource     = table;
        ddlSearchField.DataTextField  = table.Columns["Text"].ColumnName;
        ddlSearchField.DataValueField = table.Columns["Value"].ColumnName;
        ddlSearchField.AutoPostBack   = true;
        ddlSearchField.DataBind();
        ddlSearchField.SelectedIndexChanged += new System.EventHandler(BindCategories);
    }
Beispiel #2
0
    protected void BindDataToGridView()
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        DataTable dt = new DataTable();
        DataRow   dr = null;

        dt.Columns.Add(new DataColumn("Created At", typeof(string)));
        dt.Columns.Add(new DataColumn("User Name", typeof(string)));
        dt.Columns.Add(new DataColumn("Status", typeof(string)));
        dt.Columns.Add(new DataColumn("Edit", typeof(string)));
        dt.Columns.Add(new DataColumn("Change Password", typeof(string)));

        foreach (var x in _sms_EMAIL_DB_Entities.tbl_Users.Where(x => x.Role != "Admin").OrderBy(x => x.Created_At).ToList())
        {
            dr = dt.NewRow();
            dr["Created At"]      = DateTimeHelper.ConvertToString(x.Created_At.ToString());
            dr["User Name"]       = x.User_Name;
            dr["Status"]          = x.Status;
            dr["Edit"]            = x.Id;
            dr["Change Password"] = x.Id;
            dt.Rows.Add(dr);
        }

        gvUsers.DataSource = dt;
        gvUsers.DataBind();
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var userName = txtUserName.Text.Trim();

        if (hdnCurrentUserName.Value != txtUserName.Text.Trim())
        {
            var count = _sms_EMAIL_DB_Entities.tbl_Users.Where(x => x.User_Name == userName).Count();
            if (count > 0)
            {
                Session["ErrorMessage"] = "User with the user name already exists!";
                return;
            }
        }
        var userId = int.Parse(hdnUserId.Value);
        var user   = _sms_EMAIL_DB_Entities.tbl_Users.Where(x => x.Id == userId).First();

        user.User_Name  = userName;
        user.Status     = ddlStatus.SelectedValue;
        user.Updated_At = DateTime.Now;
        user.Can_Search = ckbSearch.Checked;
        _sms_EMAIL_DB_Entities.SaveChanges();
        Session["NoticeMessage"] = "Successfully updated the user!";
        Response.Redirect("index.aspx");
    }
Beispiel #4
0
    protected void btnResend_Click(object sender, EventArgs e)
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var smsId = long.Parse(hdnFldSMSId.Value);

        sms = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Id == smsId).First();
        var phone           = sms.Mobile_Number;
        var message         = sms.Text;
        var sms_code        = SmsSender.Send(phone, message);
        var sms_code_decode = StringHelper.ConvertResponseCode(sms_code);

        sms.SMS_Code        = sms_code;
        sms.SMS_Code_Decode = sms_code_decode;
        sms.SMS_Sent_At     = DateTime.Now;
        _sms_EMAIL_DB_Entities.SaveChanges();
        tEvent = new tbl_Events {
            Created_At   = DateTime.Now,
            Code         = sms_code,
            Status       = sms_code_decode,
            Email_Sms_Id = sms.Id
        };
        _sms_EMAIL_DB_Entities.AddTotbl_Events(tEvent);
        _sms_EMAIL_DB_Entities.SaveChanges();
        Session["NoticeMessage"] = "Please check SMS status !";
        Response.Redirect("Details.aspx?id=" + smsId.ToString());
    }
Beispiel #5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        HttpPostedFile postedFile = Request.Files["smsFile"];

        if (postedFile == null || postedFile.ContentLength <= 0)
        {
            Session["ErrorMessage"] = "Please select a file";
            return;
        }
        var  outputFile = FileHelper.SaveFile(postedFile);
        long tmpId      = long.Parse(ddlTemplate.SelectedValue);
        int  userId     = CurrentUser.Id();

        _SMS_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        bulk_SMS = new tbl_Bulk_SMS
        {
            Created_At  = DateTime.Now,
            File_Name   = outputFile["FileName"].ToString(),
            File_Path   = outputFile["FilePath"].ToString(),
            Status      = "New",
            Updated_At  = DateTime.Now,
            Template_Id = tmpId,
            User_Id     = userId
        };
        _SMS_EMAIL_DB_Entities.AddTotbl_Bulk_SMS(bulk_SMS);
        _SMS_EMAIL_DB_Entities.SaveChanges();
        Response.Redirect("Index.aspx");
    }
    public static tbl_Users DBUser()
    {
        SMS_EMAIL_DB_Entities _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var currentUserId = CurrentUser.Id();
        var user          = _sms_EMAIL_DB_Entities.tbl_Users.Where(x => x.Id == currentUserId).First();

        return(user);
    }
Beispiel #7
0
    protected void lkBtnErrorDownload_Click(object sender, EventArgs e)
    {
        var lkBtn = (LinkButton)sender;
        var id    = long.Parse(lkBtn.CommandArgument.ToString());

        _SMS_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        bulk_SMS = _SMS_EMAIL_DB_Entities.tbl_Bulk_SMS.Where(x => x.Id == id).First();
        sendFile(bulk_SMS.Error_File_Name, bulk_SMS.Error_File_Path);
    }
Beispiel #8
0
 protected void BindGridView()
 {
     _SMS_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
     if (CurrentUser.Role() == "Admin")
     {
         var data = from bs in _SMS_EMAIL_DB_Entities.tbl_Bulk_SMS
                    join t in _SMS_EMAIL_DB_Entities.tbl_Templates
                    on bs.Template_Id equals t.Id
                    orderby bs.Created_At descending
                    select new
         {
             Id             = bs.Id,
             TemplateName   = t.Name,
             CreatedAt      = bs.Created_At,
             InputFileName  = bs.File_Name,
             InputFilePath  = bs.File_Path,
             OutputFilePath = bs.Output_File_Path,
             OutputFileName = bs.Output_File_Name,
             ErrorFileName  = bs.Error_File_Name,
             ErrorFilePath  = bs.Error_File_Path,
             Visible        = !string.IsNullOrEmpty(bs.Output_File_Path),
             ErrorVisible   = !string.IsNullOrEmpty(bs.Error_File_Path),
             Status         = bs.Status
         };
         gvSMS.DataSource = data;
         gvSMS.DataBind();
     }
     else
     {
         var id   = CurrentUser.Id();
         var data = from bs in _SMS_EMAIL_DB_Entities.tbl_Bulk_SMS
                    join t in _SMS_EMAIL_DB_Entities.tbl_Templates
                    on bs.Template_Id equals t.Id
                    where bs.User_Id == id
                    orderby bs.Created_At descending
                    select new
         {
             Id             = bs.Id,
             TemplateName   = t.Name,
             CreatedAt      = bs.Created_At,
             InputFileName  = bs.File_Name,
             InputFilePath  = bs.File_Path,
             OutputFilePath = bs.Output_File_Path,
             OutputFileName = bs.Output_File_Name,
             ErrorFileName  = bs.Error_File_Name,
             ErrorFilePath  = bs.Error_File_Path,
             Visible        = !string.IsNullOrEmpty(bs.Output_File_Path),
             ErrorVisible   = !string.IsNullOrEmpty(bs.Error_File_Path),
             Status         = bs.Status
         };
         gvSMS.DataSource = data;
         gvSMS.DataBind();
     }
 }
Beispiel #9
0
 protected void btnSendDuplicate_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         var phoneNumber = "966" + txtMobile.Text.Trim();
         using (_sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities())
         {
             sendSMS(phoneNumber);
         }
         Response.Redirect("Index.aspx");
     }
 }
Beispiel #10
0
 protected void AddNewTemplate(object sender, EventArgs e)
 {
     entity         = new SMS_EMAIL_DB_Entities();
     tmp            = new tbl_Templates();
     tmp.Type       = ddlNewType.SelectedValue;
     tmp.Name       = txtNewName.Text;
     tmp.Text       = txtTextNew.Text;
     tmp.Created_At = DateTime.Now;
     tmp.Updated_At = DateTime.Now;
     entity.AddTotbl_Templates(tmp);
     entity.SaveChanges();
     BindGridView();
 }
Beispiel #11
0
 protected void UpdateTemplate(object sender, GridViewUpdateEventArgs e)
 {
     Id             = long.Parse(((HiddenField)gvTemplates.Rows[e.RowIndex].FindControl("hdnFldId")).Value);
     entity         = new SMS_EMAIL_DB_Entities();
     tmp            = entity.tbl_Templates.Where(x => x.Id == Id).First();
     tmp.Type       = ((DropDownList)gvTemplates.Rows[e.RowIndex].FindControl("ddlType")).Text;
     tmp.Name       = ((TextBox)gvTemplates.Rows[e.RowIndex].FindControl("txtName")).Text;
     tmp.Text       = ((TextBox)gvTemplates.Rows[e.RowIndex].FindControl("txtText")).Text;
     tmp.Updated_At = DateTime.Now;
     entity.SaveChanges();
     gvTemplates.EditIndex = -1;
     BindGridView();
 }
Beispiel #12
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var userId   = int.Parse(hdnUserId.Value);
        var password = StringHelper.MD5Hash(txtPassword.Text.Trim());
        var user     = _sms_EMAIL_DB_Entities.tbl_Users.Where(x => x.Id == userId).First();

        user.Password   = password;
        user.Updated_At = DateTime.Now;
        _sms_EMAIL_DB_Entities.SaveChanges();
        Session["NoticeMessage"] = "Successfully changed password!";
        Response.Redirect("Index.aspx");
    }
Beispiel #13
0
    protected void btnSend_Click(object sender, EventArgs e)
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var currentUserId = CurrentUser.Id();
        var email         = new tbl_Emails_SMS {
            Claim_Number = txtClaimNumber.Text, Policy_Number = txtPolicyNumber.Text, TP_Name = txtTpName.Text, Email = txtEmail.Text, Text = txtText.Text, Type = "Email", User_Id = currentUserId, Created_At = DateTime.Now, Mobile_Number = txtMobile.Text, Email_Subject = txtSubject.Text, TP_ID = txtTPID.Text, SMS_Sent_At = DateTime.Now
        };

        _sms_EMAIL_DB_Entities.AddTotbl_Emails_SMS(email);
        _sms_EMAIL_DB_Entities.SaveChanges();
        Session["NoticeMessage"] = "Successfully send an email !";
        Mailer.SendMailMessage(txtEmail.Text.ToString().Trim(), "", "", txtSubject.Text.ToString().Trim(), txtText.Text.ToString().Trim());
        Response.Redirect("Index.aspx");
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        SMS_EMAIL_DB_Entities _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var       password = StringHelper.MD5Hash(txtPassword.Text.ToString());
        tbl_Users user     = _sms_EMAIL_DB_Entities.tbl_Users.Where(x => x.User_Name == txtUserName.Text).Where(x => x.Password == password && x.Status == "Active").FirstOrDefault();

        if (user == null)
        {
            errorDiv.Visible = true;
            return;
        }
        FormsAuthentication.SetAuthCookie(user.User_Name, false);
        FormsAuthenticationTicket ticket1 =
            new FormsAuthenticationTicket(
                1,                                   // version
                user.User_Name,                      // get username  from the form
                DateTime.Now,                        // issue time is now
                DateTime.Now.AddHours(11),           // expires in 10 minutes
                false,                               // cookie is not persistent
                user.Role + "#" + user.Id.ToString() // role assignment is stored
                );
        HttpCookie cookie1 = new HttpCookie(
            FormsAuthentication.FormsCookieName,
            FormsAuthentication.Encrypt(ticket1));

        Response.Cookies.Add(cookie1);

        int?count = user.Sign_In_Count.Equals(String.Empty) ? 0 : user.Sign_In_Count;

        user.Sign_In_Count   = count + 1;
        user.Last_Sign_In_At = DateTime.Now;
        _sms_EMAIL_DB_Entities.SaveChanges();
        String returnUrl1 = "";

        if (Request.QueryString["ReturnUrl"] != null)
        {
            returnUrl1 = Request.QueryString["ReturnUrl"];
        }
        else
        {
            returnUrl1 = CurrentUser.GetRedirectPath(user.Role);
        }
        Session["NoticeMessage"] = "Successfully logged in !";
        Response.Redirect(returnUrl1);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var emailId = long.Parse(Request.QueryString["id"]);

        if (CurrentUser.Role() == "Admin")
        {
            email = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Id == emailId).First();
        }
        else
        {
            var currentUserId = CurrentUser.Id();
            email = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Id == emailId).Where(x => x.User_Id == currentUserId).FirstOrDefault();
            if (email == null)
            {
                Response.Redirect("NotAuthorized.aspx");
                return;
            }
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
         hdnUserId.Value        = Request.QueryString["id"];
         var userId = int.Parse(hdnUserId.Value);
         var user   = _sms_EMAIL_DB_Entities.tbl_Users.Where(x => x.Id == userId).Where(x => x.Role != "Admin").FirstOrDefault();
         if (user == null)
         {
             Session["ErrorMessage"] = "You are not authorizrd to acces this user!";
             Response.Redirect("Index.aspx");
             return;
         }
         txtUserName.Text         = user.User_Name;
         ddlStatus.SelectedValue  = user.Status;
         hdnCurrentUserName.Value = user.User_Name;
         ckbSearch.Checked        = user.Can_Search.Value;
     }
 }
Beispiel #17
0
 protected void btnSend_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         var phoneNumber = "966" + txtMobile.Text.Trim();
         //id = long.Parse(ddlTemplate.SelectedValue);
         using (_sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities())
         {
             var count = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Mobile_Number == phoneNumber).Count();
             if (count == 0)
             {
                 sendSMS(phoneNumber);
                 Response.Redirect("Index.aspx");
                 return;
             }
         }
         btnSend.Visible         = false;
         duplicateSmsDiv.Visible = true;
     }
 }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var    currentUserId   = CurrentUser.Id();
        string currentPassword = StringHelper.MD5Hash(txtCurrentPassword.Text.Trim());
        var    user            = _sms_EMAIL_DB_Entities.tbl_Users.Where(x => x.Id == currentUserId).First();

        if (currentPassword != user.Password)
        {
            Session["ErrorMessage"] = "You current password is in correct!";
            return;
        }
        var password = StringHelper.MD5Hash(txtPassword.Text.Trim());

        user.Password   = password;
        user.Updated_At = DateTime.Now;
        _sms_EMAIL_DB_Entities.SaveChanges();
        Session["NoticeMessage"] = "Successfully changed your password!";
        Response.Redirect(CurrentUser.GetRedirectPath(CurrentUser.Role()));
    }
Beispiel #19
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var userName = txtUserName.Text.Trim();

        if (_sms_EMAIL_DB_Entities.tbl_Users.Where(x => x.User_Name == userName).FirstOrDefault() != null)
        {
            Session["ErrorMessage"] = "User with same user name already exists!";
            return;
        }
        var password    = StringHelper.MD5Hash(txtPassword.Text.Trim());
        var currentTime = DateTime.Now;
        var user        = new tbl_Users {
            User_Name = userName, Password = password, Role = "Normal_User", Can_Search = ckbSearch.Checked,
            Status    = ddlStatus.SelectedValue, Sign_In_Count = 0, Created_At = currentTime, Updated_At = currentTime
        };

        _sms_EMAIL_DB_Entities.AddTotbl_Users(user);
        _sms_EMAIL_DB_Entities.SaveChanges();
        Session["NoticeMEssage"] = "Successfully created a new user";
        Response.Redirect("Index.aspx");
    }
 protected void AddNewTemplate(object sender, EventArgs e)
 {
     _text = txtTextNew.Text;
     if (ddlNewType.SelectedValue == "BULK_SMS_DYNAMIC" && !_text.Contains("{variable}"))
     {
         lblErrorN.Visible = true;
         return;
     }
     lblErrorN.Visible = false;
     entity            = new SMS_EMAIL_DB_Entities();
     tmp            = new tbl_Templates();
     tmp.Type       = ddlNewType.SelectedValue;
     tmp.Name       = txtNewName.Text;
     tmp.Text       = txtTextNew.Text;
     tmp.Created_At = DateTime.Now;
     tmp.Updated_At = DateTime.Now;
     entity.AddTotbl_Templates(tmp);
     entity.SaveChanges();
     BindGridView();
     txtNewName.Text          = string.Empty;
     txtTextNew.Text          = string.Empty;
     ddlNewType.SelectedValue = "SMS";
 }
    protected void UpdateTemplate(object sender, GridViewUpdateEventArgs e)
    {
        _text     = ((TextBox)gvTemplates.Rows[e.RowIndex].FindControl("txtText")).Text;
        _lblError = gvTemplates.Rows[e.RowIndex].FindControl("lblError") as Label;
        var ddl = ((DropDownList)gvTemplates.Rows[e.RowIndex].FindControl("ddlType"));

        if (ddl.SelectedValue == "BULK_SMS_DYNAMIC" && !_text.Contains("{variable}"))
        {
            _lblError.Visible = true;
            return;
        }
        _lblError.Visible = false;
        Id             = long.Parse(((HiddenField)gvTemplates.Rows[e.RowIndex].FindControl("hdnFldId")).Value);
        entity         = new SMS_EMAIL_DB_Entities();
        tmp            = entity.tbl_Templates.Where(x => x.Id == Id).First();
        tmp.Type       = ddl.SelectedValue;
        tmp.Name       = ((TextBox)gvTemplates.Rows[e.RowIndex].FindControl("txtName")).Text;
        tmp.Text       = _text;
        tmp.Updated_At = DateTime.Now;
        entity.SaveChanges();
        gvTemplates.EditIndex = -1;
        BindGridView();
    }
Beispiel #22
0
    protected void BindDataToGridView()
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        DataTable dt = new DataTable();
        DataRow   dr = null;

        dt.Columns.Add(new DataColumn("Sent At", typeof(string)));
        dt.Columns.Add(new DataColumn("Sent To", typeof(string)));
        dt.Columns.Add(new DataColumn("Sent By", typeof(string)));
        dt.Columns.Add(new DataColumn("Details", typeof(string)));

        List <tbl_Emails_SMS> list;

        if (CurrentUser.Role() == "Admin")
        {
            list = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Type == "Email").OrderByDescending(x => x.Created_At).ToList();
        }
        else
        {
            var currentUserId = CurrentUser.Id();
            list = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Type == "Email").Where(x => x.User_Id == currentUserId).OrderByDescending(x => x.Created_At).ToList();
        }

        foreach (var x in list)
        {
            dr            = dt.NewRow();
            dr["Sent At"] = DateTimeHelper.ConvertToString(x.Created_At.ToString());
            dr["Sent To"] = x.Email;
            dr["Sent By"] = x.tbl_Users.User_Name;
            dr["Details"] = x.Id;
            dt.Rows.Add(dr);
        }

        gvEmails.DataSource = dt;
        gvEmails.DataBind();
    }
 protected void BindDdlUsersRoot(DropDownList ddlRoot, bool active = true)
 {
     using (_entity = GetEntity())
     {
         var data = from u in _entity.tbl_Users
                    //where u.Status == "Active"
                    orderby u.User_Name
                    select new
         {
             Name = u.User_Name,
             Id   = u.Id,
             Role = u.Role
         };
         lstTV = new List <TextValue>();
         foreach (var x in data)
         {
             objTV = new TextValue {
                 Text = x.Name, Value = x.Id.ToString()
             };
             lstTV.Add(objTV);
         }
     }
     BindDDlRoot(ddlRoot);
 }
Beispiel #24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        var smsId = long.Parse(Request.QueryString["id"]);

        if (CurrentUser.Role() == "Admin")
        {
            sms = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Id == smsId).First();
        }
        else
        {
            var currentUserId = CurrentUser.Id();
            sms = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Id == smsId).Where(x => x.User_Id == currentUserId).FirstOrDefault();
            if (sms == null)
            {
                Response.Redirect("NotAuthorized.aspx");
                return;
            }
        }
        hdnFldSMSId.Value   = smsId.ToString();
        btnResend.Visible   = sms.SMS_Code_Decode != "Success";
        gvEvents.DataSource = sms.tbl_Events;
        gvEvents.DataBind();
    }
Beispiel #25
0
 protected void BindGridView()
 {
     entity = new SMS_EMAIL_DB_Entities();
     gvTemplates.DataSource = entity.tbl_Templates.ToList();
     gvTemplates.DataBind();
 }
Beispiel #26
0
    protected void BindDataToGridView()
    {
        _sms_EMAIL_DB_Entities = new SMS_EMAIL_DB_Entities();
        DataTable dt = new DataTable();
        DataRow   dr = null;

        dt.Columns.Add(new DataColumn("Sent At", typeof(string)));
        dt.Columns.Add(new DataColumn("Sent To", typeof(string)));
        dt.Columns.Add(new DataColumn("Sent By", typeof(string)));
        dt.Columns.Add(new DataColumn("Status", typeof(string)));
        dt.Columns.Add(new DataColumn("Details", typeof(string)));

        IQueryable <tbl_Emails_SMS> ls;
        List <tbl_Emails_SMS>       list;

        if (CurrentUser.Role() == "Admin")
        {
            ls = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Type == "SMS");
        }
        else
        {
            var currentUserId = CurrentUser.Id();
            ls = _sms_EMAIL_DB_Entities.tbl_Emails_SMS.Where(x => x.Type == "SMS").Where(x => x.User_Id == currentUserId);
        }

        switch (ddlSearchField.SelectedValue)
        {
        case "Mobile Number":
            ls = ls.Where(x => x.Mobile_Number.Contains(txtField.Text));
            break;

        case "Date":
            var      date = txtSentDate.Text;
            DateTime startDate, endDate;
            DateTimeHelper.GetStartAndEndTime(date, out startDate, out endDate);
            ls = ls.Where(x => x.SMS_Sent_At >= startDate).Where(x => x.SMS_Sent_At <= endDate);
            break;

        case "Sent By":
            ls = ls.Where(x => x.tbl_Users.User_Name.Contains(txtField.Text));
            break;

        case "Policy No.":
            ls = ls.Where(x => x.Policy_Number.Contains(txtField.Text));
            break;

        case "Claim No.":
            ls = ls.Where(x => x.Claim_Number.Contains(txtField.Text));
            break;

        default: break;
        }
        list = ls.OrderByDescending(x => x.Created_At).ToList();

        foreach (var x in list)
        {
            dr            = dt.NewRow();
            dr["Sent At"] = x.SMS_Sent_At.ToString();
            dr["Sent To"] = x.Mobile_Number;
            dr["Sent By"] = x.tbl_Users.User_Name;
            dr["Status"]  = x.SMS_Code_Decode;
            dr["Details"] = x.Id;
            dt.Rows.Add(dr);
        }
        gvSMS.DataSource = dt;
        gvSMS.DataBind();
    }
 protected SMS_EMAIL_DB_Entities GetEntity()
 {
     _entity = new SMS_EMAIL_DB_Entities();
     return(_entity);
 }