private void button1_Click(object sender, EventArgs e) { Alert alert = new Alert(); 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.ExistsName(alert.提醒项目)) { if (MessageBox.Show("系统中已经存在该提醒,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { int id = al.AddAlert(alert); if (id > 0) { alert.ID = id; LoadAlerts(); MessageBox.Show("添加成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { int id = al.AddAlert(alert); if (id > 0) { alert.ID = id; LoadAlerts(); MessageBox.Show("添加成功!"); } } }
private void button1_Click(object sender, EventArgs e) { Alert alert = new Alert(); 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.ExistsName(alert.提醒项目)) { if (MessageBox.Show("系统中已经存在该提醒,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { int id = al.AddAlert(alert); if (id > 0) { alert.ID = id; LoadAlerts(); MessageBox.Show("添加成功!"); } } else { textBox1.Focus(); textBox1.SelectAll(); } } else { int id = al.AddAlert(alert); if (id > 0) { alert.ID = id; LoadAlerts(); MessageBox.Show("添加成功!"); } } }