예제 #1
0
        public static bool validateWarningTracker(string equipment)
        {
            bool val = false;

            try
            {
                string    query = "Select EquipID from tblWarningTracker where EquipID='" + equipment + "'";
                DataTable dt    = new DataTable();
                dt = DBModel.CustomSelectQuery(query);

                if (dt != null)
                {
                    string query2 = "";
                    if (dt.Rows.Count == 0)
                    {
                        query2 = "Insert into tblWarningTracker(EquipID,Tier) values ('" + equipment + "',NULL)";
                        try
                        {
                            val = DBModel.ExecuteCustomQuery(query2);
                        }
                        catch
                        {
                            val = false;
                        }
                    }
                }
            }
            catch
            {
                val = false;
            }

            return(val);
        }
예제 #2
0
        //function for deleting user group
        public static bool DeleteUserGroup(int UserModeCode)
        {
            bool result = false;

            try
            {
                string query = "Delete UserModeTable where UserModeCode=" + UserModeCode;

                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("User Role", "Deleted User Role - ID: " + UserModeCode.ToString(), HostName, IP, HttpContext.Current.Session["Username"].ToString());
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #3
0
        public static bool clearTrackedEquipment(string equipment)
        {
            bool val = false;

            try
            {
                string query = "Update EquipmentTable set Process=NULL, UserInProcess=NULL, LotInProcess=NULL, TrackInToleranceQty=NULL, TrackInQty=NULL, RecipeInProcess=NULL where EquipID='" + equipment + "'";
                DBModel.ExecuteCustomQuery(query);

                query = "Update EquipmentQty set ProcessedQty=NULL,EndQty=NULL,TotalQty=NULL,isBranded=NULL,BrandedQty=NULL,UnbrandedQty=NULL where EquipmentID='" + equipment + "'";
                DBModel.ExecuteCustomQuery(query);

                query = "Update tblSECSGEM_Qty set Qty=NULL,Qty2=NULL,Multiplier=NULL where EquipID='" + equipment + "'";
                DBModel.ExecuteCustomQuery(query);

                query = "Update tblWarningTracker set Tier=NULL where EquipID='" + equipment + "'";
                DBModel.ExecuteCustomQuery(query);

                val = true;
            }
            catch
            {
                val = false;
            }

            return(val);
        }
예제 #4
0
        public static void ValidateSECSGEMQty(string EquipID, int Multiplier)
        {
            string query  = "select EquipID from tblSECSGEM_Qty where EquipID='" + EquipID + "'";
            string query2 = "insert into tblSECSGEM_Qty(EquipID,Qty,Qty2,Multiplier) values ('" + EquipID + "',NULL,NULL," + Multiplier.ToString() + ")";

            try
            {
                DataTable dt = new DataTable();
                dt = DBModel.CustomSelectQuery(query);
                if (dt == null)
                {
                    DBModel.ExecuteCustomQuery(query2);
                }
                else
                {
                    if (dt.Rows.Count == 0)
                    {
                        DBModel.ExecuteCustomQuery(query2);
                    }
                    else
                    {
                        query2 = "Update tblSECSGEM_Qty set Multiplier=" + Multiplier.ToString() + " where EquipID='" + EquipID + "'";
                        DBModel.ExecuteCustomQuery(query2);
                    }
                }
            }
            catch { }
        }
예제 #5
0
        //function for adding user group
        public static bool AddUserGroup(string UserModeDesc, bool isEnabled)
        {
            bool result = false;

            try
            {
                string query = "";

                if (isEnabled == true)
                {
                    query = "Insert into UserModeTable(UserModeDesc,isLoginOverride) values('" + UserModeDesc + "', 1)";
                }
                else
                {
                    query = "Insert into UserModeTable(UserModeDesc,isLoginOverride) values('" + UserModeDesc + "', 0)";
                }

                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("User Role", "Added User Role - User Role: " + UserModeDesc, HostName, IP, HttpContext.Current.Session["Username"].ToString());
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #6
0
        public static bool updateEquipmentTrackIn(int quantity, string equipment, string LotNo, string UserID, string Recipe)
        {
            bool val = false;

            try
            {
                double tolerance = HttpHandler.tolerance;
                double percent   = tolerance / 100;

                double toleranceQuantity = quantity * percent;

                int value = Convert.ToInt32(Math.Ceiling(toleranceQuantity));

                string query = "Update EquipmentTable set Process=1, UserInProcess='" + UserID.ToString().ToUpper() + "', RecipeInProcess='" + Recipe + "', LotInProcess='" + LotNo + "', TrackInToleranceQty=" + value + ", TrackInQty=" + quantity.ToString() + " where EquipID='" + equipment + "'";
                DBModel.ExecuteCustomQuery(query);

                val = true;
            }
            catch
            {
                val = false;
            }

            return(val);
        }
        //for deleting equipment group from table
        public static bool DeleteMachineGroup(string id)
        {
            bool result = false;

            try
            {
                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  = "delete EquipmentTable where ID=" + tempID;
                        result = DBModel.ExecuteCustomQuery(query);

                        if (result == true)
                        {
                            query  = "delete tblEquipmentGroup where ID=" + id;
                            result = DBModel.ExecuteCustomQuery(query);

                            if (result == true)
                            {
                                result = DeleteMachineGroupRelation(id);

                                if (result == true)
                                {
                                    query  = "delete tblGroupEnrollment where GroupID=" + id;
                                    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("Group Settings", "Deleted Equipment Group - ID: " + id, HostName, IP, HttpContext.Current.Session["Username"].ToString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #8
0
        public static bool markAsBrand(string equipment, string isBranded)
        {
            string checkQuery = "select EquipmentID from EquipmentQty where EquipmentID='" + equipment + "'";

            DataTable dt = new DataTable();

            try
            {
                dt = DBModel.CustomSelectQuery(checkQuery);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        string query  = "update EquipmentQty set isBranded=" + isBranded + " where EquipmentID='" + equipment + "'";
                        bool   result = false;

                        try
                        {
                            result = DBModel.ExecuteCustomQuery(query);
                        }
                        catch
                        {
                            result = false;
                        }

                        return(result);
                    }
                    else
                    {
                        string query = "Insert into EquipmentQty(EquipmentID,isBranded) values ('" + equipment + "'," + isBranded + ")";

                        bool result = false;

                        try
                        {
                            result = DBModel.ExecuteCustomQuery(query);
                        }
                        catch
                        {
                            result = false;
                        }

                        return(result);
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
예제 #9
0
        public static void AddLog(string Module, string Description, string ComputerName, string IPAddress, string UserID)
        {
            string query = "Insert into tblAuditLogs(Module,Description,ComputerName,IPAddress,UserID,Date) values('" + Module + "','" + Description + "','" + ComputerName + "','" + IPAddress + "','" + UserID + "',getdate())";

            try
            {
                DBModel.ExecuteCustomQuery(query);
            }
            catch { }
        }
예제 #10
0
        public static bool UpdatePrintReelTable(string EquipID, int ReelQty, int CurrentQty, int CurrentReel, int TotalReel, int RemainingReel, int AllowedReel, int InReel)
        {
            bool result = false;

            string query = "Select EquipID from PrintTable where EquipID='" + EquipID + "'";

            DataTable dt = new DataTable();

            try
            {
                dt = DBModel.CustomSelectQuery(query);

                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        result = true;
                    }
                    else
                    {
                        result = false;
                    }
                }
                else
                {
                    result = false;
                }
            }
            catch
            {
                result = false;
            }

            if (result == false)
            {
                query = "Insert into PrintTable(EquipID,ReelQty,CurrentReel,TotalReel,RemainingReel,CurrentQty,AllowedReel,InReel) values('" + EquipID + "'," + ReelQty.ToString() + "," + CurrentReel.ToString() + "," + TotalReel.ToString() + "," + RemainingReel.ToString() + "," + CurrentQty.ToString() + "," + AllowedReel.ToString() + "," + InReel.ToString() + ")";
            }
            else
            {
                query = "Update PrintTable set ReelQty=" + ReelQty.ToString() + "," + "CurrentQty=" + CurrentQty.ToString() + "," + "AllowedReel=" + AllowedReel.ToString() + "," + "InReel=" + InReel.ToString() + "," + "CurrentReel=" + CurrentReel.ToString() + "," + "TotalReel=" + TotalReel.ToString() + "," + "RemainingReel=" + RemainingReel.ToString() + " where EquipID='" + EquipID + "'";
            }

            bool output = false;

            try
            {
                output = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                output = false;
            }

            return(output);
        }
        //for deleting equipment group relation from table
        public static bool DeleteMachineGroupRelation(string id)
        {
            bool result = false;

            try
            {
                List <string> lstEquipID = new List <string>();

                string query = "";
                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)
                        {
                            lstEquipID.Add(dr["EquipID"].ToString());
                        }
                    }
                }

                query  = "delete MachineGroupRelationTable where groupID=" + id;
                result = DBModel.ExecuteCustomQuery(query);

                if (result == true)
                {
                    if (lstEquipID != null)
                    {
                        if (lstEquipID.Count > 0)
                        {
                            foreach (string temp in lstEquipID)
                            {
                                MarkEquipmentAsUngrouped(temp);
                            }
                        }
                    }

                    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 Assignment - ID: " + id, HostName, IP, HttpContext.Current.Session["Username"].ToString());
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #12
0
        //function for saving access rights
        public static bool SaveSettings(int UserModeCode, int ModuleID, bool isEnabled)
        {
            bool result = true;

            try
            {
                int bitEnabled = 0;

                if (isEnabled == true)
                {
                    bitEnabled = 1;
                }

                DataTable dt = new DataTable();
                dt = Library.ConnectionString.returnCon.executeSelectQuery("SELECT Id FROM tblPermissions WHERE UserModeCode=" + UserModeCode.ToString() + " AND ModuleId=" + ModuleID.ToString(), CommandType.Text);

                string query = "";
                if (dt.Rows.Count > 0)
                {
                    int ID = 0;
                    foreach (DataRow dr in dt.Rows)
                    {
                        ID = Convert.ToInt32(dr["Id"].ToString());
                    }

                    if (bitEnabled == 0)
                    {
                        query = "Delete tblPermissions WHERE Id=" + ID.ToString();
                    }
                    else
                    {
                        query = "Update tblPermissions SET UserModeCode=" + UserModeCode.ToString() + ",ModuleID=" + ModuleID.ToString() + " WHERE Id=" + ID.ToString();
                    }

                    result = DBModel.ExecuteCustomQuery(query);
                }
                else
                {
                    if (bitEnabled == 1)
                    {
                        query  = "Insert into tblPermissions(UserModeCode,ModuleId) values(" + UserModeCode.ToString() + "," + ModuleID.ToString() + ")";
                        result = DBModel.ExecuteCustomQuery(query);
                    }
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
        //for inserting equipment group table
        public static bool AddMachineGroupRelation(int groupID, int equipID)
        {
            bool result = false;

            try
            {
                string query = "";
                query  = "insert into MachineGroupRelationTable(GroupID,EquipID) values(" + groupID.ToString() + "," + equipID.ToString() + ")";
                result = DBModel.ExecuteCustomQuery(query);

                if (result == true)
                {
                    query = "select isEnabled from tblEquipmentGroup where ID=" + groupID.ToString();
                    DataTable dt = new DataTable();
                    dt = DBModel.CustomSelectQuery(query);

                    bool isEnabled = false;

                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            foreach (DataRow dr in dt.Rows)
                            {
                                isEnabled = Convert.ToBoolean(dr["isEnabled"]);
                            }
                        }
                    }

                    if (isEnabled == true)
                    {
                        result = MarkEquipmentAsGrouped(equipID.ToString());
                    }
                    else
                    {
                        result = MarkEquipmentAsUngrouped(equipID.ToString());
                    }

                    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 Assignment - ID: " + groupID, HostName, IP, HttpContext.Current.Session["Username"].ToString());
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #14
0
        //function for deleting access rights
        public static bool DeletePermission(int UserModeCode)
        {
            bool result = false;

            try
            {
                string query = "Delete tblPermissions WHERE UserModeCode=" + UserModeCode.ToString();
                result = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #15
0
        public static bool ClearReelTable(string EquipID)
        {
            bool   result = false;
            string query  = "Update PrintTable set ReelQty=null,CurrentQty=null,CurrentReel=null,TotalReel=null,RemainingReel=null,AllowedReel=null,InReel=null where EquipID='" + EquipID + "'";

            try
            {
                result = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #16
0
        public static bool insertTCPNotification(string equipment, string message, string type)
        {
            bool result = false;

            try
            {
                string query = "insert into TCPNotificationsTable(EquipmentId,MessageText,ReadNotification,MessageType,Date) values('" + equipment + "','" + message + "',0,'" + type + "',getdate())";
                result = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #17
0
        //function for updating batch user group
        public static bool ResetUserByBatch(int UserModeCode)
        {
            bool result = false;

            try
            {
                string query = "Update Users set UserModeCode=null where UserModeCode=" + UserModeCode.ToString();
                result = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #18
0
        public static bool markAsReadSECSGEM(string id)
        {
            string query  = "update NotificationsTable set ReadNotification=1 where MessageId='" + id + "'";
            bool   result = false;

            try
            {
                result = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #19
0
        //function to delete equipment by batch
        public static bool DeleteUserEquipmentByBatch(string equipID)
        {
            bool result = false;

            try
            {
                string query = "Delete from UserEquipmentTable where EquipID=" + equipID;
                result = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                result = false;
            }

            return(result);
        }
        public static bool MarkEquipmentAsUngrouped(string ID)
        {
            bool result = false;

            try
            {
                string query = "update EquipmentTable set IsGrouped=null where ID=" + ID;
                result = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #21
0
        //function for deleting equipment by type
        public static bool DeleteEquipmentByType(string typeCode)
        {
            bool result = false;

            string query = "delete from EquipmentTable where EquipType=" + typeCode.ToString();

            try
            {
                result = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #22
0
        //for updating equipment type table
        public static bool UpdateEquipmentType(string id, string type, bool isEnabled, bool isSECSGEM)
        {
            bool result = false;

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

                string bit2 = "";
                if (isSECSGEM == true)
                {
                    bit2 = "1";
                }
                else
                {
                    bit2 = "0";
                }

                string query = "update tblEquipmentType set Type='" + type + "',IsEnabled=" + bit.ToString() + ",IsSECSGEM=" + bit2.ToString() + " where ID=" + id;
                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("Machine Type", "Updated Machine Type - ID: " + id, HostName, IP, HttpContext.Current.Session["Username"].ToString());
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #23
0
        public static bool UpdateCounter(string EquipID, int AllowedReel, int CurrentReel, int RemainingReel)
        {
            string query = "";

            query = "Update PrintTable set AllowedReel=" + AllowedReel.ToString() + "," + "CurrentReel=" + CurrentReel.ToString() + "," + "RemainingReel=" + RemainingReel.ToString() + " where EquipID='" + EquipID + "'";

            bool result = false;

            try
            {
                result = DBModel.ExecuteCustomQuery(query);
            }
            catch
            {
                result = false;
            }

            return(result);
        }
        //for inserting equipment group table
        public static bool AddMachineGroup(string name, bool isEnabled)
        {
            bool result = false;

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

                string query = "insert into tblEquipmentGroup(GroupName,IsEnabled) values('" + name + "'," + bit.ToString() + ")";
                result = DBModel.ExecuteCustomQuery(query);

                if (result == true)
                {
                    query  = "insert into EquipmentTable(EquipID,EquipType,EquipModel,EquipSerialNum,EquipData,TimeStamp,EquipIP,EquipPort,HostID,DeviceID) values('" + name + "',0,'','','',getdate(),'','','','')";
                    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("Group Settings", "Added Equipment Group - Name: " + name, HostName, IP, HttpContext.Current.Session["Username"].ToString());
                    }
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #25
0
        public static bool UpdateEnrollment(string ID, string username, string groupID, string host)
        {
            bool result = false;

            try
            {
                string query = "Update tblGroupEnrollment set GroupID=" + groupID + ",UserID='" + username + "',HostID='" + host + "' where ID=" + ID.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("Group Enrollment", "Updated Group Enrollment - ID: " + ID, HostName, IP, HttpContext.Current.Session["Username"].ToString());
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #26
0
        //for deleting equipment type from table
        public static bool DeleteEquipmentType(string id)
        {
            bool result = false;

            try
            {
                string query = "delete tblEquipmentType where ID=" + id;
                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("Machine Type", "Deleted Machine Type - ID: " + id, HostName, IP, HttpContext.Current.Session["Username"].ToString());
                }
            }
            catch
            {
                result = false;
            }

            return(result);
        }
예제 #27
0
        //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);
        }
        //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);
        }