private void ModifyCamBtn_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count <= 0) { MessageHelper.ShowWarning("请选择相机列表中的任一相机再修改!"); return; } int iRow = dataGridView1.SelectedRows[0].Index; if (iRow >= 0) { string camName = dataGridView1.Rows[iRow].Cells[0].Value.ToString(); string camType = dataGridView1.Rows[iRow].Cells[2].Value.ToString(); CameraManger.RemoveCameraInfo(camName); if (!string.IsNullOrEmpty(CamNameTxt.Text) && CamTypeComBox.SelectedItem != null) { if (CameraManger.AddCameraInfo(CamNameTxt.Text, CamTypeComBox.SelectedItem.ToString())) { dataGridView1.Rows[iRow].Cells[0].Value = CamNameTxt.Text; dataGridView1.Rows[iRow].Cells[1].Value = CamTypeComBox.Text; CamNameTxt.Clear(); MessageHelper.ShowTips("修改相机成功!"); return; } } CameraManger.AddCameraInfo(camName, camType); MessageHelper.ShowWarning("修改相机失败!"); } CamNameTxt.Clear(); }
private void AddCamBtn_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(CamNameTxt.Text)) { MessageHelper.ShowWarning("pls input the valid name of Cam"); return; } if (CamTypeComBox.SelectedItem == null) { MessageHelper.ShowWarning("pls select a type of this Cam"); return; } CameraManger.AddCameraInfo(CamNameTxt.Text.Trim(), CamTypeComBox.SelectedItem.ToString()); if (CameraManger.GetCameraInfoInstance(CamNameTxt.Text) != null) { DataGridViewRow newrow = new DataGridViewRow(); DataGridViewTextBoxCell namecell = new DataGridViewTextBoxCell(); namecell.Value = CamNameTxt.Text.Trim(); DataGridViewTextBoxCell TypecbCell = new DataGridViewTextBoxCell(); TypecbCell.Value = CamTypeComBox.SelectedItem.ToString(); newrow.Cells.Add(namecell); newrow.Cells.Add(TypecbCell); dataGridView1.Rows.Add(newrow); CamNameTxt.Clear(); } else { MessageHelper.ShowError("添加相机失败"); } }