Beispiel #1
0
        private void SaveContent()
        {
            if (!ContentChanged)
            {
                return;
            }

            String cID    = String.Empty;
            String sQuery = String.Concat("SELECT ContentID FROM [Employers] WHERE EmployerID = ", ddlEmployers.SelectedValue);
            String uQuery = "UPDATE [EmployerContent] SET ";

            try
            {
                using (BaseCCHData b = new BaseCCHData(sQuery, true))
                {
                    b.GetFrontEndData();
                    if (b.HasErrors)
                    {
                        throw new Exception("Error finding Content in database");
                    }
                    cID = b.Tables[0].Rows[0][0].ToString();
                }

                List <KeyValuePair <String, object> > l = Changes.Where(kvp => kvp.Value != null).ToList <KeyValuePair <String, object> >();
                l.ForEach(delegate(KeyValuePair <String, object> kvp)
                {
                    uQuery = String.Concat(uQuery, kvp.Key, " = '", kvp.Value, "'");
                    if (kvp.Key != l.Last().Key)
                    {
                        uQuery = String.Concat(uQuery, ", ");
                    }
                });
                if (cID == String.Empty)
                {
                    throw new Exception("Could not find content ID in the table");
                }
                uQuery = String.Concat(uQuery, " WHERE CMID = '", cID, "'");
                using (BaseCCHData b = new BaseCCHData(uQuery, true))
                {
                    b.PostFrontEndData();
                    if (b.HasErrors)
                    {
                        throw new Exception("Error updating content with changes");
                    }
                }
                this.feedback = feedback.Append("Changes Saved Successfully");
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Page.Header.Controls.Add(new LiteralControl("<link rel=\"stylesheet\" href=\"" + ResolveUrl("~/Styles/Notify.css") + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\" type=\"text/css\" />"));
                ThisSession.UserLogginID = Membership.GetUser().ProviderUserKey.ToString();

                using (BaseCCHData employees = new BaseCCHData("GetBNCUserInfoForAdmin"))
                {
                    employees.GetFrontEndData();
                    if (employees.Tables.Count >= 1 && employees.Tables[0].Rows.Count > 0)
                    {
                        this.Employees = (from employee in employees.Tables[0].AsEnumerable()
                                          select new EmployeeData()
                                          {
                                              UserId = employee.Field<object>("userid"),
                                              UserName = employee.Field<object>("username"),
                                              Locked = employee.Field<object>("IsLockedOut"),
                                              EmployerID = employee.Field<object>("employerid"),
                                              ConnectionString = employee.Field<object>("connectionstring"),
                                              DataBase = employee.Field<object>("DataBase"),
                                              CCHID = employee.Field<object>("CCHID")
                                          }).ToDictionary(k => k.UserId.ToString(), v => v);
                    }
                    var t = this.Employees.Select(Em => new { Em.Value.UserName, Em.Value.UserId }).OrderBy(Em => Em.UserName).ToList();
                    ddlUsers.DataBind(t);
                    if (employees.Tables.Count >= 2 && employees.Tables[1].Rows.Count > 0)
                    {
                        this.EmployeesInRoles = (from role in employees.Tables[1].AsEnumerable()
                                                 select new RoleData()
                                                 {
                                                     UserId = role.Field<object>("userid"),
                                                     RoleName = role.Field<object>("rolename"),
                                                     UserName = role.Field<object>("username")
                                                 }).ToLookup(k => k.UserId.ToString(), v => v);
                    }
                    if (employees.Tables.Count >= 3 && employees.Tables[2].Rows.Count > 0)
                    {
                        this.Orphans = (from orphan in employees.Tables[2].AsEnumerable()
                                        select new EmployeeData()
                                        {
                                            UserId = orphan.Field<object>("userid"),
                                            UserName = orphan.Field<object>("username")
                                        }).ToDictionary(k => k.UserId.ToString(), v => v);
                    }
                    t = this.Orphans.Select(Or => new { Or.Value.UserName, Or.Value.UserId }).ToList();
                    ddlOrphans.DataBind(t);
                }
                
            }
        }
Beispiel #3
0
        private void SetContent()
        {
            String cmQuery =
                "select " +
                String.Concat <String>(
                    emptyChanges
                    .Keys
                    .Where <String>(key =>
                                    key == "employerid" ||
                                    key == "EmployerName" ||
                                    key == "Insurer" ||
                                    key == "RXProvider" ||
                                    key == "ShowYourCostColumn")
                    .Select <String, String>(key =>
                                             "e." + key + ", ")) +
                String.Concat <String>(
                    emptyChanges
                    .Keys
                    .Where(k =>
                           k != "ContentManagementEnabled" &&
                           k != "employerid" &&
                           k != "EmployerName" &&
                           k != "Insurer" &&
                           k != "RXProvider" &&
                           k != "ShowYourCostColumn")
                    .Select <String, String>(k =>
                                             "ec." + k + ", ")) +
                "CASE WHEN ec.cmid is null THEN 0 ELSE 1 END as ContentManagementEnabled " +
                "from employers e " +
                "left join employercontent ec on e.contentid = ec.cmid";

            using (BaseCCHData b = new BaseCCHData(cmQuery, true))
            {
                b.GetFrontEndData();

                if (b.Tables.Count > 0)
                {
                    this.content = b.Tables[0];
                }
            }
        }
Beispiel #4
0
        private void DisableCM()
        {
            String oldID           = String.Empty;
            String qUpdateEmpEntry = String.Concat(
                "UPDATE [Employers] SET ContentID = NULL OUTPUT Deleted.ContentID WHERE EmployerID = ", ddlEmployers.SelectedValue);
            String qRemCMEntry = "DELETE FROM [EmployerContent] WHERE CMID = '{0}'";

            try
            {
                using (BaseCCHData b = new BaseCCHData(qUpdateEmpEntry, true))
                {
                    b.GetFrontEndData();
                    if (b.HasErrors)
                    {
                        throw new Exception("Error  unlinking content from employer");
                    }
                    oldID = b.Tables[0].Rows[0][0].ToString();
                }
                if (oldID == String.Empty)
                {
                    throw new Exception("Could not find previous content ID");
                }
                using (BaseCCHData b = new BaseCCHData(String.Format(qRemCMEntry, oldID), true))
                {
                    b.PostFrontEndData();
                    if (b.HasErrors)
                    {
                        throw new Exception("Error removing old content from table");
                    }
                }
                this.feedback = feedback.Append(
                    String.Concat(
                        "Content Management Removed from ",
                        ddlEmployers.SelectedItem.Text,
                        " Successfully"));
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #5
0
        private void SetContent()
        {
            String cmQuery =
                "select " +
                String.Concat<String>(
                    emptyChanges
                        .Keys
                        .Where<String>(key =>
                            key == "employerid" ||
                            key == "EmployerName" ||
                            key == "Insurer" ||
                            key == "RXProvider" ||
                            key == "ShowYourCostColumn")
                        .Select<String, String>(key =>
                            "e." + key + ", ")) +
                String.Concat<String>(
                    emptyChanges
                        .Keys
                        .Where(k =>
                            k != "ContentManagementEnabled" &&
                            k != "employerid" &&
                            k != "EmployerName" &&
                            k != "Insurer" &&
                            k != "RXProvider" &&
                            k != "ShowYourCostColumn")
                        .Select<String, String>(k =>
                            "ec." + k + ", ")) +
                "CASE WHEN ec.cmid is null THEN 0 ELSE 1 END as ContentManagementEnabled " +
                    "from employers e " +
                    "left join employercontent ec on e.contentid = ec.cmid";

            using (BaseCCHData b = new BaseCCHData(cmQuery, true))
            {
                b.GetFrontEndData();

                if(b.Tables.Count > 0)
                    this.content = b.Tables[0];
            }
        }
Beispiel #6
0
        private void SaveContent()
        {
            if (!ContentChanged) return;

            String cID = String.Empty;
            String sQuery = String.Concat("SELECT ContentID FROM [Employers] WHERE EmployerID = ", ddlEmployers.SelectedValue);
            String uQuery = "UPDATE [EmployerContent] SET ";
            try
            {
                using (BaseCCHData b = new BaseCCHData(sQuery, true))
                {
                    b.GetFrontEndData();
                    if (b.HasErrors) throw new Exception("Error finding Content in database");
                    cID = b.Tables[0].Rows[0][0].ToString();
                }

                List<KeyValuePair<String, object>> l = Changes.Where(kvp => kvp.Value != null).ToList<KeyValuePair<String, object>>();
                l.ForEach(delegate(KeyValuePair<String, object> kvp)
                {
                    uQuery = String.Concat(uQuery, kvp.Key, " = '", kvp.Value, "'");
                    if (kvp.Key != l.Last().Key) uQuery = String.Concat(uQuery, ", ");
                });
                if (cID == String.Empty) throw new Exception("Could not find content ID in the table");
                uQuery = String.Concat(uQuery, " WHERE CMID = '", cID, "'");
                using (BaseCCHData b = new BaseCCHData(uQuery, true))
                {
                    b.PostFrontEndData();
                    if (b.HasErrors) throw new Exception("Error updating content with changes");
                }
                this.feedback = feedback.Append("Changes Saved Successfully");
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #7
0
        private void DisableCM()
        {
            String oldID = String.Empty;
            String qUpdateEmpEntry = String.Concat(
                "UPDATE [Employers] SET ContentID = NULL OUTPUT Deleted.ContentID WHERE EmployerID = ", ddlEmployers.SelectedValue);
            String qRemCMEntry = "DELETE FROM [EmployerContent] WHERE CMID = '{0}'";

            try
            {
                using (BaseCCHData b = new BaseCCHData(qUpdateEmpEntry, true))
                {
                    b.GetFrontEndData();
                    if (b.HasErrors) throw new Exception("Error  unlinking content from employer");
                    oldID = b.Tables[0].Rows[0][0].ToString();
                }
                if (oldID == String.Empty) throw new Exception("Could not find previous content ID");
                using (BaseCCHData b = new BaseCCHData(String.Format(qRemCMEntry, oldID), true))
                {
                    b.PostFrontEndData();
                    if (b.HasErrors) throw new Exception("Error removing old content from table");
                }
                this.feedback = feedback.Append(
                    String.Concat(
                        "Content Management Removed from ",
                        ddlEmployers.SelectedItem.Text,
                        " Successfully"));
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Page.Header.Controls.Add(new LiteralControl("<link rel=\"stylesheet\" href=\"" + ResolveUrl("~/Styles/Notify.css") + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\" type=\"text/css\" />"));
                ThisSession.UserLogginID = Membership.GetUser().ProviderUserKey.ToString();

                using (BaseCCHData employees = new BaseCCHData("GetBNCUserInfoForAdmin"))
                {
                    employees.GetFrontEndData();
                    if (employees.Tables.Count >= 1 && employees.Tables[0].Rows.Count > 0)
                    {
                        this.Employees = (from employee in employees.Tables[0].AsEnumerable()
                                          select new EmployeeData()
                                          {
                                              UserId = employee.Field<object>("userid"),
                                              UserName = employee.Field<object>("username"),
                                              Locked = employee.Field<object>("IsLockedOut"),
                                              EmployerID = employee.Field<object>("employerid"),
                                              ConnectionString = employee.Field<object>("connectionstring"),
                                              DataBase = employee.Field<object>("DataBase"),
                                              CCHID = employee.Field<object>("CCHID")
                                          }).ToDictionary(k => k.UserId.ToString(), v => v);
                    }
                    var t = this.Employees.Select(Em => new { Em.Value.UserName, Em.Value.UserId }).OrderBy(Em => Em.UserName).ToList();
                    ddlUsers.DataBind(t);
                    if (employees.Tables.Count >= 2 && employees.Tables[1].Rows.Count > 0)
                    {
                        this.EmployeesInRoles = (from role in employees.Tables[1].AsEnumerable()
                                                 select new RoleData()
                                                 {
                                                     UserId = role.Field<object>("userid"),
                                                     RoleName = role.Field<object>("rolename"),
                                                     UserName = role.Field<object>("username")
                                                 }).ToLookup(k => k.UserId.ToString(), v => v);
                    }
                    if (employees.Tables.Count >= 3 && employees.Tables[2].Rows.Count > 0)
                    {
                        this.Orphans = (from orphan in employees.Tables[2].AsEnumerable()
                                        select new EmployeeData()
                                        {
                                            UserId = orphan.Field<object>("userid"),
                                            UserName = orphan.Field<object>("username")
                                        }).ToDictionary(k => k.UserId.ToString(), v => v);
                    }
                    t = this.Orphans.Select(Or => new { Or.Value.UserName, Or.Value.UserId }).ToList();
                    ddlOrphans.DataBind(t);
                }

            }
        }