private void btnAdd_Click() { try { string beginTime = dtp_beginTime.Text.Trim(); string endTime = dtp_endTime.Text.Trim(); string begin = beginTime + " 00:00:00"; string end = endTime + "23:59:59 "; if (!GetBool()) { return; } var addBeonduty = new Beonduty { Beonduty_BeginTime = Common.GetDateTime(begin), //开始时间 Beonduty_EndTime = Common.GetDateTime(end), //结束时间 Beonduty_Dictionary_ID = Common.GetInt(cob_Beonduty_Dictionary_Name.SelectedValue), //状态 Beonduty_Remake = txtRemark.Text.Trim(), //备注 QCGroup_ID = Common.GetInt(cob_QCGroup_Name.SelectedValue) //小组 }; if (BeondutyDAL.InsertOneQCRecord(addBeonduty)) { string Log_Content = String.Format("值班开始时间:{0} 值班结束时间:{1}", begin, end); Common.WriteLogData("新增", "新增值班信息" + Log_Content, Common.NAME); //操作日志 MessageBox.Show("添加成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("添加失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { Common.WriteTextLog("Beonduty_GuanLǐ.btnAdd_Click()" + ex.Message.ToString()); } finally { //更新数据 page = new PageControl(); page.PageMaxCount = tscbxPageSize2.SelectedItem.ToString(); LoadData();//更新数据 } }
/// <summary> /// 新增一条记录 /// </summary> /// <param name="qcRecord">质检实体</param> /// <returns></returns> public static bool InsertOneQCRecord(Beonduty qcRecord) { bool rbool = true; using (DCQUALITYDataContext db = new DCQUALITYDataContext()) { try { db.Beonduty.InsertOnSubmit(qcRecord); db.SubmitChanges(); rbool = true; } catch { rbool = false; } finally { db.Connection.Close(); } } return(rbool); }