예제 #1
0
        private void RefreshVideo()
        {
            VideoRecRepository repo = new VideoRecRepository();

            videoRecList = repo.GetList();
            dataGridView_CameraInfo.DataSource = videoRecList;
        }
예제 #2
0
        private void buttonX_Del_Click(object sender, EventArgs e)
        {
            if (dataGridView_CameraInfo.SelectedRows.Count <= 0)
            {
                MessageBox.Show("请先选中一行数据");
                return;
            }
            var  row      = dataGridView_CameraInfo.SelectedRows[0];
            long ID       = (long)(row.Cells[0].Value);
            var  videoRec = videoRecList.Find(_ => _.ID == ID);

            if (videoRec == null)
            {
                MessageBox.Show("数据错误");
                return;
            }

            if (DialogResult.Yes != MessageBox.Show("确定删除该行信息?", "提示", MessageBoxButtons.YesNo))
            {
                return;
            }
            try
            {
                VideoRecRepository repo = new VideoRecRepository();
                repo.Delete(ID);
                RefreshVideo();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #3
0
        private void buttonX_Save_Click(object sender, EventArgs e)
        {
            VideoRecRepository repo = new VideoRecRepository();

            try
            {
                if (operType.Equals("Add"))
                {
                    VideoRec newVR = new VideoRec();
                    newVR.VideoRecPath = textBoxX_Path.Text;
                    newVR.VideoRecName = textBoxX_Name.Text;
                    newVR.RecTime      = dateTimeInput_Time.Value;
                    newVR.RecLocation  = textBoxX_Location.Text;
                    newVR.RecSrc       = textBoxX_Src.Text;
                    newVR.EventType    = textBoxX_EventType.Text;
                    newVR.Description  = textBoxX_Description.Text;
                    repo.Insert(newVR);
                }
                else
                {
                    vr.VideoRecPath = textBoxX_Path.Text;
                    vr.VideoRecName = textBoxX_Name.Text;
                    vr.RecTime      = dateTimeInput_Time.Value;
                    vr.RecLocation  = textBoxX_Location.Text;
                    vr.RecSrc       = textBoxX_Src.Text;
                    vr.EventType    = textBoxX_EventType.Text;
                    vr.Description  = textBoxX_Description.Text;
                    repo.Update(vr);
                }
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #4
0
        private void buttonX_Search_Click(object sender, EventArgs e)
        {
            StringBuilder searchCondition = new StringBuilder(" where 1=1");

            if (!dateTimeInput_TimeStart.IsEmpty)
            {
                searchCondition.Append(" and RecTime>@RecTimeStart");
            }
            if (!dateTimeInput_TimeEnd.IsEmpty)
            {
                searchCondition.Append(" and RecTime<@RecTimeEnd");
            }
            if (!string.IsNullOrWhiteSpace(textBoxX_Location.Text))
            {
                searchCondition.Append(" and RecLocation like @RecLocation");
            }
            if (!string.IsNullOrWhiteSpace(textBoxX_Src.Text))
            {
                searchCondition.Append(" and RecSrc like @RecSrc");
            }
            if (!string.IsNullOrWhiteSpace(textBoxX_EventType.Text))
            {
                searchCondition.Append(" and EventType like @EventType");
            }

            VideoRecRepository repo = new VideoRecRepository();

            videoRecList = repo.GetListWithCondition(searchCondition.ToString(), new
            {
                RecTimeStart = dateTimeInput_TimeStart.Value,
                RecTimeEnd   = dateTimeInput_TimeEnd.Value,
                RecLocation  = "%" + textBoxX_Location.Text + "%",
                RecSrc       = "%" + textBoxX_Src.Text + "%",
                EventType    = "%" + textBoxX_EventType.Text + "%"
            });
            dataGridView_CameraInfo.DataSource = videoRecList;
        }