protected void btnAddToCt_Click(object sender, EventArgs e)
 {
     try 
     {
         adminTableAdapters.GetCreditTeamMembersTableAdapter ctMember = new adminTableAdapters.GetCreditTeamMembersTableAdapter();
         ctMember.InsertCreditTeamMember(Convert.ToInt32(ddlCreditTeamID.SelectedValue),
                                         Convert.ToInt32(ddlStaff.SelectedValue));
         ShowMessageBox("New credit team member added");
     }
     catch (Exception ex) { }
 }
 protected void btnAddToCt_Click(object sender, EventArgs e)
 {
     try
     {
         adminTableAdapters.GetCreditTeamMembersTableAdapter ctMember = new adminTableAdapters.GetCreditTeamMembersTableAdapter();
         ctMember.InsertCreditTeamMember(Convert.ToInt32(ddlCreditTeamID.SelectedValue),
                                         Convert.ToInt32(ddlStaff.SelectedValue));
         ShowMessageBox("New credit team member added");
     }
     catch (Exception ex) { }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (MySessionManager.CurrentUser == null)
        {
            Response.Redirect("~/logout.aspx");
        }
        try
        {
            if (Request.QueryString["ctid"] != null)
            {
                currentCT.Value = Request.QueryString["ctid"];

                SqlDataSource5.SelectParameters[0].DefaultValue = currentCT.Value;
                gvCtMembers.DataSourceID = "SqlDataSource5";
                gvCtMembers.DataBind();

                if (Request.QueryString["id"] != null)
                {
                    int id = Convert.ToInt32(Request.QueryString["id"]);
                    if (Request.QueryString["action"] =="edit")
                    {
                        try
                        {
                            adminTableAdapters.GetCreditTeamMembersTableAdapter ctMembers = new adminTableAdapters.GetCreditTeamMembersTableAdapter();
                            admin.GetCreditTeamMembersDataTable tblCTMembers = ctMembers.GetCTMemberDetails(id);
                            if(tblCTMembers.Rows.Count > 0)
                            {
                                ddlStaff.SelectedValue = tblCTMembers[0].datSysUserID.ToString();
                                ddlBranch.SelectedValue = tblCTMembers[0].branchID.ToString();
                                ddlCreditTeamID.SelectedValue = tblCTMembers[0].datCreditTeamID.ToString();
                            }
                        }
                        catch(Exception ex){}
                    }
                    else if (Request.QueryString["action"] == "delete")
                    {
                        adminTableAdapters.GetCreditTeamMembersTableAdapter ctMembers = new adminTableAdapters.GetCreditTeamMembersTableAdapter();
                        ctMembers.DeleteCTMember(id);
                        ShowMessageBox("A member has been removed from the team");
                    }
                
                }
            }
        }
        catch (Exception ex) { Page.Response.Redirect(util.RemoveQueryStringByKey(HttpContext.Current.Request.Url.AbsoluteUri, "ctid")); }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (MySessionManager.CurrentUser == null)
        {
            Response.Redirect("~/logout.aspx");
        }
        try
        {
            if (Request.QueryString["ctid"] != null)
            {
                currentCT.Value = Request.QueryString["ctid"];

                SqlDataSource5.SelectParameters[0].DefaultValue = currentCT.Value;
                gvCtMembers.DataSourceID = "SqlDataSource5";
                gvCtMembers.DataBind();

                if (Request.QueryString["id"] != null)
                {
                    int id = Convert.ToInt32(Request.QueryString["id"]);
                    if (Request.QueryString["action"] == "edit")
                    {
                        try
                        {
                            adminTableAdapters.GetCreditTeamMembersTableAdapter ctMembers = new adminTableAdapters.GetCreditTeamMembersTableAdapter();
                            admin.GetCreditTeamMembersDataTable tblCTMembers = ctMembers.GetCTMemberDetails(id);
                            if (tblCTMembers.Rows.Count > 0)
                            {
                                ddlStaff.SelectedValue        = tblCTMembers[0].datSysUserID.ToString();
                                ddlBranch.SelectedValue       = tblCTMembers[0].branchID.ToString();
                                ddlCreditTeamID.SelectedValue = tblCTMembers[0].datCreditTeamID.ToString();
                            }
                        }
                        catch (Exception ex) {}
                    }
                    else if (Request.QueryString["action"] == "delete")
                    {
                        adminTableAdapters.GetCreditTeamMembersTableAdapter ctMembers = new adminTableAdapters.GetCreditTeamMembersTableAdapter();
                        ctMembers.DeleteCTMember(id);
                        ShowMessageBox("A member has been removed from the team");
                    }
                }
            }
        }
        catch (Exception ex) { Page.Response.Redirect(util.RemoveQueryStringByKey(HttpContext.Current.Request.Url.AbsoluteUri, "ctid")); }
    }