Example #1
0
    protected void gvCompany_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        dsUserTableAdapters.licensee4MgrTableAdapter licensee4MgrTA = new dsUserTableAdapters.licensee4MgrTableAdapter();
        dsUser.licensee4MgrDataTable licensee4MgrDT = new dsUser.licensee4MgrDataTable();

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            licensee4MgrDT = licensee4MgrTA.GetLicenseesByCID(Convert.ToInt32(gvCompany.DataKeys[e.Row.RowIndex]["ID"].ToString()));
            if (licensee4MgrDT.Rows.Count == 0)
            {
                ((HtmlImage)e.Row.FindControl("viewUserID")).Visible = false;
            }
        }

        /*
         * if (e.Row.RowType == DataControlRowType.DataRow)
         * {
         *  if (e.Row.RowType == DataControlRowType.DataRow)
         *  {
         *      //e.Row.Cells[3].Text = "<a href=\"CompanyDetail.aspx?id=" + gvUser.DataKeys[e.Row.RowIndex]["ID"].ToString() + "\">" + e.Row.Cells[3].Text + "</a>";
         *      e.Row.Cells[0].Text = "<input type=\"button\" value=\"View\" onclick=\"window.location='CompanyDetail.aspx?id=" + gvCompany.DataKeys[e.Row.RowIndex]["ID"].ToString() + "'\">";
         *      e.Row.Cells[1].Text = "<input type=\"button\" value=\" Edit \" onclick=\"window.location='EditCompany.aspx?id=" + gvCompany.DataKeys[e.Row.RowIndex]["ID"].ToString() + "'\">";
         *      e.Row.Cells[8].Text = "<input type=\"button\" value=\"Delete\" onclick=\"window.location='DeleteCompany.aspx?id=" + gvCompany.DataKeys[e.Row.RowIndex]["ID"].ToString() + "'\">";
         *  }
         * }
         */
    }
Example #2
0
    public List <user> GetUsersByCID(string cid)
    {
        string pID        = string.Empty;
        string pFirstName = string.Empty;
        string pLastName  = string.Empty;

        dsUserTableAdapters.licenseeTableAdapter licenseeTA = new dsUserTableAdapters.licenseeTableAdapter();
        dsUser.licenseeDataTable licenseeDT = new dsUser.licenseeDataTable();
        licenseeDT = licenseeTA.GetPrimaryContactByCID(Convert.ToInt32(cid));
        if (licenseeDT.Rows.Count > 0)
        {
            pID        = licenseeDT.Rows[0]["ID"].ToString();;
            pFirstName = licenseeDT.Rows[0]["FirstName"].ToString();
            pLastName  = licenseeDT.Rows[0]["LastName"].ToString();
        }

        dsUserTableAdapters.licensee4MgrTableAdapter licensee4MgrTA = new dsUserTableAdapters.licensee4MgrTableAdapter();
        dsUser.licensee4MgrDataTable licensee4MgrDT = new dsUser.licensee4MgrDataTable();
        licensee4MgrDT = licensee4MgrTA.GetLicenseesByCID(Convert.ToInt32(cid));
        for (int i = 0; i < licensee4MgrDT.Rows.Count; i++)
        {
            if (!(licensee4MgrDT.Rows[i]["UserLevel"] is DBNull))
            {
                switch (licensee4MgrDT[i].UserLevel)
                {
                case "A": licensee4MgrDT[i].Status = "<b><font color=\"cyan\">Current</font></b>"; break;

                case "B": licensee4MgrDT[i].Status = "<b><font color=\"cyan\">Current</font></b>"; break;

                case "C":
                    if (!(licensee4MgrDT.Rows[i]["AllowedYear"] is DBNull))
                    {
                        if (Convert.ToDateTime(DateTime.Now.ToShortDateString()) <= licensee4MgrDT[i].AllowedYear)
                        {
                            licensee4MgrDT[i].Status = "<b><font color=\"cyan\">Current</font></b>";
                        }
                        else
                        {
                            licensee4MgrDT[i].Status = "<b><font color=\"red\">Expired</font></b>";
                        }
                    }
                    else
                    {
                        licensee4MgrDT[i].Status = "<b>Unknown</b>";
                    }

                    break;

                case "D":
                    if (!(licensee4MgrDT.Rows[i]["FromDate"] is DBNull) && !(licensee4MgrDT.Rows[i]["ToDate"] is DBNull))
                    {
                        if ((Convert.ToDateTime(DateTime.Now.ToShortDateString()) >= licensee4MgrDT[i].FromDate) && (Convert.ToDateTime(DateTime.Now.ToShortDateString()) <= licensee4MgrDT[i].ToDate))
                        {
                            licensee4MgrDT[i].Status = "<b><font color=\"cyan\">Current</font></b>";
                        }
                        else
                        {
                            licensee4MgrDT[i].Status = "<b><font color=\"red\">Expired</font></b>";
                        }
                    }
                    else
                    {
                        licensee4MgrDT[i].Status = "<b>Unknown</b>";
                    }
                    break;

                case "X":
                    licensee4MgrDT[i].Status = "<b><font color=\"red\">Suspended</font></b>";
                    break;

                default: break;
                }
            }
        }
        List <user> users = new List <user>();

        foreach (DataRow dr in licensee4MgrDT.Rows)
        {
            user u = new user();
            u.uid            = dr["ID"].ToString();
            u.firstName      = dr["FirstName"].ToString();
            u.lastName       = dr["LastName"].ToString();
            u.email          = dr["Email"].ToString();
            u.userCategory   = dr["UserCategory"].ToString();
            u.requestorName  = dr["RequestorName"].ToString();
            u.status         = dr["Status"].ToString();
            u.cid            = cid;
            u.primaryContact = Convert.ToBoolean(dr["PrimaryContact"].ToString());
            //u.primaryContact = true;
            //u.requestorName = "Hudson Choi";
            //u.status = "Current";

            /*
             * if (dr["RequestorName"] != null)
             * {
             *  u.requestorName = dr["RequestorName"].ToString();
             * }
             * if (dr["Status"] != null)
             * {
             *  u.status = dr["Status"].ToString();
             * }
             */
            u.pid        = pID;
            u.pFirstName = pFirstName;
            u.pLastName  = pLastName;

            if (dr["RequestorEmail"] != null)
            {
                u.mlbEmail = dr["RequestorEmail"].ToString();
                u.mlbName  = dr["RequestorName"].ToString();
            }
            else
            {
                u.mlbEmail = "";
                u.mlbName  = "";
            }
            users.Add(u);
        }
        return(users);
        //List<CollectData>
        //return c;
    }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        tbSearch.Attributes.Add("onClick", "MakeItBlank()");
        //Reset the session variables to make it sense
        Session["licenseeDT"] = null;



        //dsUserTableAdapters.licenseeTableAdapter licenseeTA = new dsUserTableAdapters.licenseeTableAdapter();
        //dsUser.licenseeDataTable licenseeDT = new dsUser.licenseeDataTable();

        dsUserTableAdapters.licensee4MgrTableAdapter licensee4MgrTA = new dsUserTableAdapters.licensee4MgrTableAdapter();
        dsUser.licensee4MgrDataTable licensee4MgrDT = new dsUser.licensee4MgrDataTable();

        if ((!Page.IsPostBack) || (tbSearch.Text == "Email, Name or Company"))
        {
            //licenseeDT = licenseeTA.GetAllUsers();
            if (Request.QueryString["key"] != null)
            {
                licensee4MgrDT = licensee4MgrTA.GetLicenseeByKeyword(Server.UrlDecode(Request.QueryString["key"].ToString()));
            }
            else
            {
                licensee4MgrDT = licensee4MgrTA.GetAllUsers();
            }
        }
        else
        {
            //licenseeDT = licenseeTA.GetLicenseeByKeyword(tbSearch.Text);
            licensee4MgrDT = licensee4MgrTA.GetLicenseeByKeyword(tbSearch.Text);
        }

        for (int i = 0; i < licensee4MgrDT.Rows.Count; i++)
        {
            if (!(licensee4MgrDT.Rows[i]["UserLevel"] is DBNull))
            {
                switch (licensee4MgrDT[i].UserLevel)
                {
                case "A": licensee4MgrDT[i].Status = "<b><font color=\"cyan\">Current</font></b>"; break;

                case "B": licensee4MgrDT[i].Status = "<b><font color=\"cyan\">Current</font></b>"; break;

                case "C":
                    if (!(licensee4MgrDT.Rows[i]["AllowedYear"] is DBNull))
                    {
                        if (Convert.ToDateTime(DateTime.Now.ToShortDateString()) <= licensee4MgrDT[i].AllowedYear)
                        {
                            licensee4MgrDT[i].Status = "<b><font color=\"cyan\">Current</font></b>";
                        }
                        else
                        {
                            licensee4MgrDT[i].Status = "<b><font color=\"red\">Expired</font></b>";
                        }
                    }
                    else
                    {
                        licensee4MgrDT[i].Status = "<b>Unknown</b>";
                    }

                    break;

                case "D":
                    if (!(licensee4MgrDT.Rows[i]["FromDate"] is DBNull) && !(licensee4MgrDT.Rows[i]["ToDate"] is DBNull))
                    {
                        if ((Convert.ToDateTime(DateTime.Now.ToShortDateString()) >= licensee4MgrDT[i].FromDate) && (Convert.ToDateTime(DateTime.Now.ToShortDateString()) <= licensee4MgrDT[i].ToDate))
                        {
                            licensee4MgrDT[i].Status = "<b><font color=\"cyan\">Current</font></b>";
                        }
                        else
                        {
                            licensee4MgrDT[i].Status = "<b><font color=\"red\">Expired</font></b>";
                        }
                    }
                    else
                    {
                        licensee4MgrDT[i].Status = "<b>Unknown</b>";
                    }
                    break;

                case "X":
                    licensee4MgrDT[i].Status = "<b><font color=\"red\">Suspended</font></b>";
                    break;

                default: break;
                }
            }
        }

        gvUser.DataSource = licensee4MgrDT;
        //gvCompany.DataBind();
        gvUser.DataBind();

        lblNum.Text = "Total number of users: " + licensee4MgrDT.Rows.Count;
    }