Example #1
0
        public void Save(CoCamera camera)
        {
            var query = "SELECT * FROM Camera WHERE name = ?;";

            DbParameter[] parametersSelect =
            {
                new DbParameter("name", camera.name.ToString())
            };
            var result = DbContext.Select(query, parametersSelect);

            if (result.Count() > 0)
            {
                query = "UPDATE Camera SET status = ?, associate = ? WHERE name = ?;";
                DbParameter[] parameters =
                {
                    new DbParameter("status",    ((camera.status) ? 1 : 0).ToString()),
                    new DbParameter("associate", ((camera.associate) ? 1 : 0).ToString()),
                    new DbParameter("name",      camera.name.ToString())
                };
                DbContext.InsertOrUpdate(query, parameters);
            }
            else
            {
                query = "INSERT INTO Camera VALUES(?, ? , ?)";
                DbParameter[] parameters =
                {
                    new DbParameter("name",      camera.name.ToString()),
                    new DbParameter("status",    ((camera.status) ? 1 : 0).ToString()),
                    new DbParameter("associate", ((camera.associate) ? 1 : 0).ToString())
                };
                DbContext.InsertOrUpdate(query, parameters);
            }
        }
Example #2
0
        public List <CoCamera> GetSystemCameras()
        {
            List <CoCamera> cameras = this.daCamera.All();

            if (this.systemCamereas.Length > cameras.Count)
            {
                for (int i = 0; i < this.systemCamereas.Length; i++)
                {
                    Boolean isCreated = false;
                    for (int j = 0; j < cameras.Count; j++)
                    {
                        if (this.systemCamereas[i].Name.ToUpper() == cameras[j].name)
                        {
                            isCreated = true;
                            break;
                        }
                    }
                    if (!isCreated)
                    {
                        CoCamera camera = new CoCamera
                        {
                            name      = this.systemCamereas[i].Name.ToUpper(),
                            status    = true,
                            associate = false
                        };
                        this.daCamera.Save(camera);
                        cameras.Add(camera);
                    }
                }
            }
            else if (cameras.Count > this.systemCamereas.Length)
            {
                for (int i = 0; i < cameras.Count; i++)
                {
                    Boolean isOff = true;
                    for (int j = 0; j < this.systemCamereas.Length; j++)
                    {
                        if (this.systemCamereas[j].Name.ToUpper() == cameras[i].name)
                        {
                            isOff = false;
                            break;
                        }
                    }
                    if (isOff)
                    {
                        cameras[i].status = false;
                        this.daCamera.Save(cameras[i]);
                    }
                }
            }
            return(cameras);
        }
        private BunifuFlatButton CreateButton(CoCamera camera, int top)
        {
            BunifuFlatButton button = new BunifuFlatButton();

            button.Normalcolor  = Color.FromArgb(37, 46, 59);
            button.OnHovercolor = Color.FromArgb(58, 71, 92);
            button.BackColor    = Color.FromArgb(58, 71, 92);
            button.Activecolor  = Color.FromArgb(58, 71, 92);
            button.Iconimage    = null;
            button.Text         = camera.name + " (" + ((camera.associate) ? "Si" : "No") + ")";
            button.Top          = top;
            return(button);
        }
Example #4
0
 public void Save(CoCamera camera)
 {
     this.daCamera.Save(camera);
     this.UpdateCameras();
 }