//for updating equipment group table
        public static bool UpdateMachineGroup(string id, string name, bool isEnabled)
        {
            bool result = false;

            try
            {
                string bit = "";
                if (isEnabled == true)
                {
                    bit = "1";
                }
                else
                {
                    bit = "0";
                }

                string query = "";
                query = "select a.ID from EquipmentTable a left join tblEquipmentGroup b on a.EquipID=b.GroupName where b.ID=" + id;
                DataTable dt_temp = new DataTable();
                dt_temp = DBModel.CustomSelectQuery(query);
                string tempID = "";
                if (dt_temp != null)
                {
                    if (dt_temp.Rows.Count > 0)
                    {
                        foreach (DataRow dr_temp in dt_temp.Rows)
                        {
                            tempID = dr_temp["ID"].ToString();
                        }

                        query  = "update EquipmentTable set EquipID='" + name + "' where ID=" + tempID;
                        result = DBModel.ExecuteCustomQuery(query);

                        if (result == true)
                        {
                            query  = "update tblEquipmentGroup set GroupName='" + name + "',IsEnabled=" + bit.ToString() + " where ID=" + id;
                            result = DBModel.ExecuteCustomQuery(query);

                            if (result == true)
                            {
                                query = "select EquipID from MachineGroupRelationTable where GroupID=" + id;
                                DataTable dt = new DataTable();
                                dt = DBModel.CustomSelectQuery(query);

                                if (dt != null)
                                {
                                    if (dt.Rows.Count > 0)
                                    {
                                        foreach (DataRow dr in dt.Rows)
                                        {
                                            string EquipID = dr["EquipID"].ToString();

                                            if (isEnabled == true)
                                            {
                                                MarkEquipmentAsGrouped(EquipID);
                                            }
                                            else
                                            {
                                                MarkEquipmentAsUngrouped(EquipID);
                                            }
                                        }
                                    }
                                }

                                string[] computer_name = Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]).HostName.Split(new Char[] { '.' });
                                string   HostName      = computer_name[0].ToString().ToUpper();
                                string   IP            = HttpHandler.GetIPAddress();
                                AuditModel.AddLog("Group Settings", "Updated Equipment Group - ID: " + id, HostName, IP, HttpContext.Current.Session["Username"].ToString());
                            }
                        }
                    }
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
        //for saving config settings
        public static bool SaveConfig(bool isSignalR, double tolerance, bool isOPCTimeout, double OPCTimeout, string DefaultPassword, string NoMarkTemplate, bool isScanner, bool isHost, bool isEffectiveDate)
        {
            bool result = false;

            try
            {
                DataTable dt = new DataTable();

                string query = "select isSignalR, Tolerance, isOPCTimeout, OPCTimeout, DefaultPassword, NoMarkTemplate, isScanner, isHostEnrollment from tblSettings";

                dt = DBModel.CustomSelectQuery(query);

                string bit = "";

                if (isSignalR.ToString().ToLower() == "true")
                {
                    bit = "1";
                }
                else
                {
                    bit = "0";
                }

                string bit2 = "";

                if (isOPCTimeout.ToString().ToLower() == "true")
                {
                    bit2 = "1";
                }
                else
                {
                    bit2 = "0";
                }

                string bit3 = "";

                if (isScanner.ToString().ToLower() == "true")
                {
                    bit3 = "1";
                }
                else
                {
                    bit3 = "0";
                }

                string bit4 = "";

                if (isHost.ToString().ToLower() == "true")
                {
                    bit4 = "1";
                }
                else
                {
                    bit4 = "0";
                }

                string bit5 = "";

                if (isEffectiveDate.ToString().ToLower() == "true")
                {
                    bit5 = "1";
                }
                else
                {
                    bit5 = "0";
                }

                if (dt.Rows.Count > 0)
                {
                    query = "update tblSettings set isSignalR=" + bit.ToString() + "," + "Tolerance=" + tolerance.ToString()
                            + "," + "isOPCTimeout=" + bit2.ToString()
                            + "," + "OPCTimeout=" + OPCTimeout.ToString()
                            + "," + "isScanner=" + bit3.ToString()
                            + "," + "isHostEnrollment=" + bit4.ToString()
                            + "," + "IsEffectiveDate=" + bit5.ToString()
                            + "," + "NoMarkTemplate='" + NoMarkTemplate.ToString().ToUpper() + "'"
                            + "," + "DefaultPassword='******'";
                }
                else
                {
                    query = "insert into tblSettings(isSignalR,Tolerance,isOPCTimeout,OPCTimeout,NoMarkTemplate,DefaultPassword,isScanner,isHostEnrollment,IsEffectiveDate) values(" + bit.ToString() + "," + tolerance.ToString()
                            + "," + bit2.ToString()
                            + "," + OPCTimeout.ToString()
                            + "," + "'" + NoMarkTemplate.ToString().ToUpper() + "'"
                            + "," + "'" + DefaultPassword.ToString() + "'"
                            + "," + bit3.ToString()
                            + "," + bit4.ToString()
                            + "," + bit5.ToString()
                            + ")";
                }

                result = DBModel.ExecuteCustomQuery(query);

                if (result == true)
                {
                    string[] computer_name = Dns.GetHostEntry(HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]).HostName.Split(new Char[] { '.' });
                    string   HostName      = computer_name[0].ToString().ToUpper();
                    string   IP            = HttpHandler.GetIPAddress();
                    AuditModel.AddLog("Configuration", "Updated Configuration", HostName, IP, HttpContext.Current.Session["Username"].ToString());
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }