private void buttonX_Del_Click(object sender, EventArgs e) { if (dataGridView_ImgInfo.SelectedRows.Count <= 0) { MessageBox.Show("请先选中一行数据"); return; } var row = dataGridView_ImgInfo.SelectedRows[0]; long ID = (long)(row.Cells[0].Value); var ImgRec = imgRecList.Find(_ => _.ID == ID); if (ImgRec == null) { MessageBox.Show("数据错误"); return; } try { ImgRecRepository repo = new ImgRecRepository(); repo.Delete(ID); RefreshVideo(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void RefreshVideo() { ImgRecRepository repo = new ImgRecRepository(); imgRecList = repo.GetList(); dataGridView_ImgInfo.DataSource = imgRecList; }
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"); } ImgRecRepository repo = new ImgRecRepository(); imgRecList = 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_ImgInfo.DataSource = imgRecList; }
private void buttonX_Save_Click(object sender, EventArgs e) { ImgRecRepository repo = new ImgRecRepository(); try { if (operType.Equals("Add")) { ImgRec newImgRec = new ImgRec(); newImgRec.ImgRecPath = textBoxX_Path.Text; newImgRec.ImgRecName = textBoxX_Name.Text; newImgRec.RecTime = dateTimeInput_Time.Value; newImgRec.RecLocation = textBoxX_Location.Text; newImgRec.RecSrc = textBoxX_Src.Text; newImgRec.EventType = textBoxX_EventType.Text; newImgRec.Description = textBoxX_Description.Text; repo.Insert(newImgRec); } else { imgRec.ImgRecPath = textBoxX_Path.Text; imgRec.ImgRecName = textBoxX_Name.Text; imgRec.RecTime = dateTimeInput_Time.Value; imgRec.RecLocation = textBoxX_Location.Text; imgRec.RecSrc = textBoxX_Src.Text; imgRec.EventType = textBoxX_EventType.Text; imgRec.Description = textBoxX_Description.Text; repo.Update(imgRec); } this.DialogResult = DialogResult.OK; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }