public Dictionary<int, ChangeSynGroup> GetAllChangeSynGroup(ref string errMessage)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            var list = new Dictionary<int, ChangeSynGroup>();
            try
            {
                ChangeSynGroup synGroup;
                DeviceInfo oDevice;
                DataSet ds = ChangeSynGroupDataAccess.GetAllChangeSynGroupInfo(db);
                DataSet dsCamera;
                CameraInfo oCamera;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    synGroup = new ChangeSynGroup(ds.Tables[0].Rows[i]);
                    dsCamera = CameraDataAccess.GetCamInfoByChangeSynGroupId(db, synGroup.ChangeSynGroupId);
                    synGroup.ListCamera = new Dictionary<int, CameraInfo>();
                    foreach (DataRow drCam in dsCamera.Tables[0].Rows)
                    {
                        oCamera = new CameraInfo(drCam);
                        synGroup.ListCamera.Add(oCamera.CameraId, oCamera);
                    }

                    list.Add(synGroup.ChangeSynGroupId, synGroup);
                }
                return list;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
        public static int Insert(Database db, ChangeSynGroup oGroupInfo)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO ChangeSynGroup(");
            sbValue.Append("values(");
            sbField.Append("Name");
            sbValue.AppendFormat("'{0}'", oGroupInfo.Name);
            sbField.Append(",Description");
            sbValue.AppendFormat(",'{0}')", oGroupInfo.Description);
            string cmdText = sbField.ToString() + " " + sbValue.ToString() + "";
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
        public ChangeSynGroup GetChangeSynGroupById(ref string errMessage, int synGroupId)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                DataSet ds = ChangeSynGroupDataAccess.GetChangeSynGroupById(db, synGroupId);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return null;
                }
                CameraInfo oCamera;
                DeviceInfo oDevice;

                var synGroup = new ChangeSynGroup(ds.Tables[0].Rows[0]) {ListCamera = new Dictionary<int, CameraInfo>()};

                DataSet dsCamera = CameraDataAccess.GetCamInfoByDeviceId(db, synGroup.ChangeSynGroupId);
                synGroup.ListCamera = new Dictionary<int, CameraInfo>();
                foreach (DataRow drCam in dsCamera.Tables[0].Rows)
                {
                    oCamera = new CameraInfo(drCam);
                    synGroup.ListCamera.Add(oCamera.CameraId, oCamera);
                }
                return synGroup;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
        public int Update(ref string errMessage, ChangeSynGroup synGroup)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                return ChangeSynGroupDataAccess.Update(db, synGroup);

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return -1;
            }
        }
        public static int Update(Database db, ChangeSynGroup oGroupInfo)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("update ChangeSynGroup set");
            sb.AppendFormat(" Name='{0}'", oGroupInfo.Name);
            sb.AppendFormat(",Description='{0}'", oGroupInfo.Description);
            sb.AppendFormat(" where GroupID={0})", oGroupInfo.ChangeSynGroupId);
            string cmdText = sb.ToString();
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }