private void saveConfig_Click(object sender, EventArgs e) { this.configInfo.groupId = this.groupId.Text; this.configInfo.replyContent = this.replyContent.Text; this.configInfo.startTime = this.startTime.Value; this.configInfo.endTime = this.endTime.Value; this.configInfo.msgLen = int.Parse(this.msgLen.Text); if ("".Equals(this.configInfo.groupId) || null == this.configInfo.groupId || this.configInfo.groupId.Length == 0) { MessageBox.Show("监控群号不能为空!"); } else if (this.configInfo.msgLen <= 0) { MessageBox.Show("监控消息长度不能为空且大于零!"); } else if ("".Equals(this.configInfo.replyContent) || null == this.configInfo.replyContent || this.configInfo.replyContent.Length == 0) { MessageBox.Show("回复内容不能为空!"); } else { if (this.index >= 0) { ConfigCache.configInfosBind.RemoveAt(index); ConfigCache.configInfosBind.Insert(index, configInfo); } else { ConfigCache.configInfosBind.Add(configInfo); } ConfigCache.saveConfigToFile(); this.Close(); } }
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { DataGridViewColumn column = dataGridView.Columns[e.ColumnIndex]; if (column is DataGridViewButtonColumn && column.Name == "edit") { ConfigInfo configInfo = ConfigCache.configInfos[e.RowIndex]; AddConfig addConfig = new AddConfig(this, configInfo, e.RowIndex); addConfig.Show(); } else if (column is DataGridViewButtonColumn && column.Name == "delete") { ConfigCache.configInfosBind.RemoveAt(e.RowIndex); ConfigCache.saveConfigToFile(); } } }