paycell /groups.aspx.cs

Language C# Lines 135
MD5 Hash 5e64d8cd0177b93d4d26de7719f32aab Estimated Cost $3,172 (why?)
Repository https://bitbucket.org/xpertech/paycell View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using System.IO;
using System.Net;
using System.Xml;

public partial class groups : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            bindgrid();
        }
    }
    private void bindgrid()
    {
        grdGroups.DataSource = SqlDataSource1;
        grdGroups.DataBind();
        foreach (GridViewRow grdrow in grdGroups.Rows)
        {
            Label lblgrpid = (Label)grdrow.Cells[0].FindControl("lblgrpid");
            Label lblTotalContacts = (Label)grdrow.Cells[1].FindControl("lblTotalContacts");
            Label lblGrpname = (Label)grdrow.Cells[1].FindControl("lblGrpname");
            if (lblGrpname.Text == "Opt Outs")
            {
                grdrow.Visible = false;
            }
            object totalcontacts = SqlHelper.ExecuteScalar(GlobalVariable.con, CommandType.Text, "select count(ContactId) from tbl_groupcontacts where GroupId=" + Convert.ToInt32(lblgrpid.Text) + " and Unsubscribed='false'");
            lblTotalContacts.Text = "(" + totalcontacts.ToString() + ")";
        }
        if (grdGroups.Rows.Count > 0)
        {
            lblrecords.Visible = true;
            ddlGridPages.Visible = true;
        }
        else
        {
            lblrecords.Visible = false;
            ddlGridPages.Visible = false;
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (btnSubmit.Text != "Update")
        {
            SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "insert into tbl_group (GroupName) values('" + txtGroupname.Text.Trim() + "')");
            bindgrid();
            lblMessage.Text = "Group Saved Successfully.";
        }
        else
        {
            SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "update tbl_group set GroupName='" + txtGroupname.Text.Trim() + "' where GroupId=" + Convert.ToInt32(Session["grpid"].ToString()) + "");
            bindgrid();
            lblMessage.Text = "Group Updated Successfully.";
        }
        Response.Redirect(Request.Url.AbsoluteUri);
    }
    protected void imgbtnEditGroup_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            GridViewRow row = (GridViewRow)(sender as Control).Parent.Parent;
            int index = row.RowIndex;
            Label lblgrpid = (Label)grdGroups.Rows[index].FindControl("lblgrpid");
            Session["grpid"] = lblgrpid.Text;
            object grpname = SqlHelper.ExecuteScalar(GlobalVariable.con, CommandType.Text, "select GroupName from tbl_group where GroupId=" + Convert.ToInt32(lblgrpid.Text) + "");
            txtGroupname.Text = grpname.ToString();
            btnAddGroup_ModalPopupExtender.Show();
            btnSubmit.Text = "Update";
        }
        catch (Exception exp)
        {
 
        }
    }
    protected void lmgbtnSendText_Click(object sender, ImageClickEventArgs e)
    {
        GridViewRow row = (GridViewRow)(sender as Control).Parent.Parent;
        int index = row.RowIndex;
        Label lblgrpid = (Label)grdGroups.Rows[index].FindControl("lblgrpid");
        Session["smsgrpid"] = lblgrpid.Text;
        Response.Redirect("sendsms.aspx");
    }
    protected void imgbtnContacts_Click(object sender, ImageClickEventArgs e)
    {
        GridViewRow row = (GridViewRow)(sender as Control).Parent.Parent;
        int index = row.RowIndex;
        Label lblgrpid = (Label)grdGroups.Rows[index].FindControl("lblgrpid");
        Session["smsgrpid"] = lblgrpid.Text;
        Response.Redirect("contacts.aspx");
    }
    protected void grdGroups_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grdGroups.PageSize = e.NewPageIndex;
        bindgrid();
    }
    protected void imgbtnDeleteGroup_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            GridViewRow row = (GridViewRow)(sender as Control).Parent.Parent;
            int index = row.RowIndex;
            Label lblgrpid = (Label)grdGroups.Rows[index].FindControl("lblgrpid");
            SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "delete from tbl_groupcontacts where GroupId=" + Convert.ToInt32(lblgrpid.Text) + "");
            SqlHelper.ExecuteNonQuery(GlobalVariable.con, CommandType.Text, "delete from tbl_group where GroupId=" + Convert.ToInt32(lblgrpid.Text) + "");
            bindgrid();
            string SelectGroup = "Group deleted successfully.";
            Page.Controls.Add(new LiteralControl("<script language='javascript'> window.alert('" + SelectGroup + "')</script>"));
        }
        catch (Exception exp)
        {
            string SelectGroup = "Some error occured. Try again later.";
            Page.Controls.Add(new LiteralControl("<script language='javascript'> window.alert('" + SelectGroup + "')</script>"));
        }
    }
    protected void ddlGridPages_SelectedIndexChanged(object sender, EventArgs e)
    {
        //ddlGridPages.PageSize = Convert.ToInt32(ddlGridPages.SelectedValue);
        //bindgrid();
    }
}
Back to Top