protected void btnSave_OnClick(object sender, EventArgs e) {
            using (var hrsgEntities = new HRSG_DatabaseEntities()) {
                var industry = hrsgEntities.Industries.Create();

                industry.Created = DateTime.Now;
                industry.Modified = DateTime.Now;
                industry.Active = true;
                industry.Name = txtbxIndustryName.Text;

                hrsgEntities.Industries.Add(industry);
                hrsgEntities.SaveChanges();

                ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndSave();", true);
            }
        }
        protected void btnSave_OnClick(object sender, EventArgs e) {
            using (var hrsgEntities = new HRSG_DatabaseEntities()) {
                var section = hrsgEntities.Sections.FirstOrDefault(a => a.ID == SectionID && a.Active);

                if (section != null) {
                    section.Modified = DateTime.Now;
                    section.Description = txtbxSectionName.Text;
                    section.Value = txtbxSectionValue.Text;

                    hrsgEntities.SaveChanges();
                }

                ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndSave();", true);
            }
        }
        protected void btnSave_OnClick(object sender, EventArgs e) {
            using (var hrsgEntities = new HRSG_DatabaseEntities()) {
                var section = hrsgEntities.Sections.Create();

                section.Created = DateTime.Now;
                section.Modified = DateTime.Now;
                section.Active = true;
                section.Description = txtbxSectionName.Text;
                section.Value = txtbxSectionValue.Text;

                hrsgEntities.Sections.Add(section);
                hrsgEntities.SaveChanges();

                ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "CloseAndSave();", true);
            }
        }
        protected void rgClients_OnItemCommand(object sender, GridCommandEventArgs e)
        {
            using (var hrsgEntities = new HRSG_DatabaseEntities()) {
                switch (e.CommandName) {
                    case "Edit":

                        break;

                    case "Delete":
                        var id = Convert.ToInt32(e.CommandArgument);    //LINQ does not understand Convert.ToInt(), convert it before passing to the expression
                        var client = hrsgEntities.Clients.FirstOrDefault(a => a.ID == id && a.Active);

                        if (client != null)
                        {
                            client.Active = false;
                            hrsgEntities.SaveChanges();
                        }
                        break;
                }
            }
        }
        protected void rgSubsections_OnItemCommand(object sender, GridCommandEventArgs e) {
            

            using (var hrsgEntities = new HRSG_DatabaseEntities()) {
                switch (e.CommandName) {
                    case "Edit":
                        var item = e.Item as GridDataItem;
                        var itemID = item["ID"].Text;

                        ClientScript.RegisterStartupScript(Page.GetType(), "mykey", $"OpenEditSubSection({itemID});", true);
                        break;

                    case "Delete":
                        var id = Convert.ToInt32(e.CommandArgument);    //LINQ does not understand Convert.ToInt(), convert it before passing to the expression
                        var subsection = hrsgEntities.SubSections.FirstOrDefault(a => a.ID == id && a.Active);

                        if (subsection != null) {
                            subsection.Active = false;
                            hrsgEntities.SaveChanges();
                        }
                        break;
                }
            }
        }