private void button2_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { Alert alert = (Alert)comboBox1.SelectedItem; alert.提醒项目 = textBox1.Text.Trim(); alert.提醒方式 = (提醒方式)comboBox3.SelectedItem; if (alert.提醒方式 == 提醒方式.系统提示 || alert.提醒方式 == 提醒方式.员工短信) { alert.提醒对象 = Commons.GetStaffIdStr(selectStaffControl1.SelectedStaffs); } else if (alert.提醒方式 == 提醒方式.会员短信) { alert.提醒对象 = Commons.GetMemberIdStr(selectMemberControl1.SelectedMembers); } alert.提醒时间 = dateTimePicker1.Value; alert.Flag = checkBox1.Checked ? 1 : 0; alert.备注 = textBox3.Text; AlertLogic al = AlertLogic.GetInstance(); if (al.ExistsNameOther(alert.提醒项目, alert.ID)) { if (MessageBox.Show("系统中已经存在该提醒,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { if (al.UpdateAlert(alert)) { LoadAlerts(); MessageBox.Show("修改成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { if (al.UpdateAlert(alert)) { LoadAlerts(); MessageBox.Show("修改成功!"); } } } else { MessageBox.Show("先选定要修改的提醒!"); } }
private void button2_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { Alert alert = new Alert(); alert.ID = ((Alert)comboBox1.SelectedItem).ID; alert.提醒项目 = textBox1.Text.Trim(); alert.提醒对象 = textBox2.Text.Trim(); alert.提醒时间 = dateTimePicker1.Value; alert.提醒方式 = comboBox3.SelectedItem as AlertType; alert.备注 = textBox3.Text.Trim(); AlertLogic al = AlertLogic.GetInstance(); if (al.ExistsNameOther(alert.提醒项目, alert.ID)) { if (MessageBox.Show("系统中已经存在该提醒,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { if (al.UpdateAlert(alert)) { LoadAlerts(); MessageBox.Show("修改成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { if (al.UpdateAlert(alert)) { LoadAlerts(); MessageBox.Show("修改成功!"); } } } else { MessageBox.Show("先选定要修改的提醒!"); } }