Exemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Trim()=="")
            {
                return;
            }
            SynGroup ogroup = new SynGroup();
            ogroup.Name = txtName.Text;
            ogroup.Description =txtDescription.Text;
            errMessage = "";
            switch (Opt)
            {
                case Util.Operateion.Add:
                    GeroupId = SynGroupBusiness.Instance.Insert(ref errMessage, ogroup);
                    OperateLogBusiness.Instance.Insert(ref errMessage, new OperateLog
                       {
                           HappenTime = DateTime.Now,
                           ClientUserId = MainForm.CurrentUser.UserId,
                           ClientUserName = MainForm.CurrentUser.UserName,
                           Content = ogroup.ToString(),
                           OperateTypeId =(int) OperateLogTypeId.SynGroupAdd,
                           OperateTypeName = OperateLogTypeName.SynGroupAdd,
                           OperateUserName = MainForm.CurrentUser.UserName

                       });
                    break;
                case Util.Operateion.Update:
                    //ogroup.GroupID = GeroupId;
                    GeroupId = SynGroupBusiness.Instance.Update(ref errMessage, ogroup);

                    OperateLogBusiness.Instance.Insert(ref errMessage, new OperateLog
                    {
                        HappenTime = DateTime.Now,
                        ClientUserId = MainForm.CurrentUser.UserId,
                        ClientUserName = MainForm.CurrentUser.UserName,
                        Content = ogroup.ToString(),
                        OperateTypeId = (int)OperateLogTypeId.SynGroupUpdate,
                        OperateTypeName = OperateLogTypeName.SynGroupUpdate,
                        OperateUserName = MainForm.CurrentUser.UserName

                    });
                    break;
                case Util.Operateion.Delete:
                    break;
                default:
                    break;
            }
            if (errMessage.Length == 0)
            {
                this.Close();
            }
        }
Exemplo n.º 2
0
        public int Update(ref string errMessage, SynGroup synGroup)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                return SynGroupDataAccess.Update(db, synGroup);

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return -1;
            }
        }
Exemplo n.º 3
0
        public SynGroup GetSynGroupBySynGroupName(ref string errMessage, string synGroupName)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            try
            {
                DataSet ds = SynGroupDataAccess.GetSynGroupBySynGroupName(db, synGroupName);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    return null;
                }
                CameraInfo oCamera;
                DeviceInfo oDevice;

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

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

                //}
                CameraMonitorPairInfo cameraMonitorPair;
                DataSet dsCameraMonitorPair = CameraMonitorPairDataAccess.GetCameraMonitorPairBySynGroupId(db, synGroup.SynGroupId);
                synGroup.ListCameraMonitorPair = new Dictionary<int, CameraMonitorPairInfo>();
                foreach (DataRow drCamMonPair in dsCameraMonitorPair.Tables[0].Rows)
                {
                    cameraMonitorPair = new CameraMonitorPairInfo(drCamMonPair);
                    synGroup.ListCameraMonitorPair.Add(cameraMonitorPair.CameraMonitorPairId, cameraMonitorPair);
                }
                return synGroup;

            }
            catch (Exception ex)
            {
                errMessage = ex.Message + ex.StackTrace;
                Logger.Error("Error Message:" + ex.Message + " Trace:" + ex.StackTrace);
                return null;
            }
        }
Exemplo n.º 4
0
        public Dictionary<int, SynGroup> GetAllSynGroups(ref string errMessage)
        {
            Database db = DatabaseFactory.CreateDatabase();
            errMessage = "";
            var list = new Dictionary<int, SynGroup>();
            try
            {
                SynGroup synGroup;
                DeviceInfo oDevice;
                DataSet ds = SynGroupDataAccess.GetAllSynGroupInfo(db);
                DataSet dsCamera;
                CameraInfo oCamera;
                DataSet dsCameraMonitorPair;
                CameraMonitorPairInfo cameraMonitorPair;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    synGroup = new SynGroup(ds.Tables[0].Rows[i]);
                    //dsCamera = CameraDataAccess.GetCamInfoBySynGroupId(db, synGroup.SynGroupId);
                    //synGroup.ListCamera = new Dictionary<int, CameraInfo>();
                    //foreach (DataRow drCam in dsCamera.Tables[0].Rows)
                    //{
                    //    oCamera = new CameraInfo(drCam);
                    //    synGroup.ListCamera.Add(oCamera.CameraId, oCamera);
                    //}
                    dsCameraMonitorPair = CameraMonitorPairDataAccess.GetCameraMonitorPairBySynGroupId(db, synGroup.SynGroupId);
                    synGroup.ListCameraMonitorPair = new Dictionary<int, CameraMonitorPairInfo>();
                    foreach (DataRow drCamMonPair in dsCameraMonitorPair.Tables[0].Rows)
                    {
                        cameraMonitorPair = new CameraMonitorPairInfo(drCamMonPair);
                        synGroup.ListCameraMonitorPair.Add(cameraMonitorPair.CameraMonitorPairId, cameraMonitorPair);
                    }

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

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

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Exemplo n.º 6
0
        public static int Insert(Database db, SynGroup oGroupInfo)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO SynGroup(");
            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;
            }
        }