private void btn_save_Click(object sender, EventArgs e) { try { string name = txt_name.Text.Trim(); string chongfu = cb_chongfu.Text; string state = cb_state.Text; DateTime temp_date2 = new DateTime(); if (dateTimePicker1.Text != "请选择") { temp_date2 = dateTimePicker1.Value; } if (chongfu == "无") { chongfu = "0"; } else if (chongfu == "每天") { chongfu = "1"; } else if (chongfu == "每月") { chongfu = "2"; } else { chongfu = "3"; } if (state == "未处理") { state = "1"; } else if (state == "已完成") { state = "2"; } string content = txt_context.Text.Trim(); basic_task bt = new basic_task(); if (taskid != 0) { bt = BLL.basic_taskManager.SearchByID(taskid); } bt.btcontent = content; bt.btdate = temp_date2; bt.btname = name; bt.btspare1 = chongfu; bt.btstate = state; if (taskid == 0) { bt.btdate2 = DateTime.Now; BLL.basic_taskManager.Insert(bt); } else { BLL.basic_taskManager.Update(bt); } bind(); MessageBox.Show("保存成功"); } catch (Exception ex) { MessageBox.Show("保存错误" + ex.ToString()); } }