public Dictionary<int, WindowCameraInfo> GetAllWindowCameraInfo(ref string errMessage)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            Dictionary<int, WindowCameraInfo> list = new Dictionary<int, WindowCameraInfo>();
            try
            {

                DataSet ds = WindowCameraDataAccess.GetAllWindowCameraInfo(db);

                WindowCameraInfo windowCameraInfo;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    windowCameraInfo = new WindowCameraInfo(ds.Tables[0].Rows[i]);
                    list.Add(windowCameraInfo.Id, windowCameraInfo);
                }
                return list;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
 public int Insert(ref string errMessage, WindowCameraInfo windowCameraInfo)
 {
     Database db = DatabaseFactory.CreateDatabase();
     errMessage = "";
     try
     {
         return WindowCameraDataAccess.IsWindowCameraExisted(db, windowCameraInfo.Row, windowCameraInfo.Col)
                    ? WindowCameraDataAccess.Update(db, windowCameraInfo.Row, windowCameraInfo.Col,
                                                    windowCameraInfo.CameraId)
                    : WindowCameraDataAccess.Insert(db, windowCameraInfo);
     }
     catch (Exception ex)
     {
         errMessage = ex.Message + ex.StackTrace;
         logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
         return -1;
     }
 }
        public static int Insert(Database db, WindowCameraInfo windowCameraInfo)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO  [WindowCameraInfo](");
            sbValue.Append("values (");
            sbField.Append("[row]");
            sbValue.AppendFormat("{0}", windowCameraInfo.Row);
            sbField.Append(",[col]");
            sbValue.AppendFormat(",{0}", windowCameraInfo.Col);
            sbField.Append(",[Camera])");
            sbValue.AppendFormat(",{0})", windowCameraInfo.CameraId);

            string cmdText = sbField.ToString() + " " + sbValue.ToString();
            try
            {
                cmdText = cmdText.Replace("\r\n", "");
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }