/// <summary> /// insert /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_save_Click(object sender, EventArgs e) { AccidentRcd model = new AccidentRcd(); try { //判断设备是否存在 string name = txt_DevCode.Text.Trim(); List<CY.GFive.Core.Business.DeviceInfo> listDeviceInfo = CY.GFive.Core.Business.DeviceInfo.GetDevicesByName(name) as List<CY.GFive.Core.Business.DeviceInfo>; if (listDeviceInfo==null||listDeviceInfo.Count == 0) { lab_Error.Text = "该设备不存在"; txt_DevCode.Text = ""; txt_DevCode.Focus(); return; } model.AccidentDate = Convert.ToDateTime(txt_AccidentDate.Text.Trim()); model.AccinenterName = txt_AccinenterName.Text.Trim(); model.ClsRoomCode = ddl_Workshop.SelectedValue; model.DevCode = txt_DevCode.Text.Trim(); model.DevUnitCode = ddl_DevUnitCode.SelectedValue.ToString(); model.LeaderName = txt_LeaderName.Text.Trim(); model.Reason = txt_Reason.Text.Trim(); model.ReportDate = Convert.ToDateTime(txt_ReportDate.Text.Trim()); model.ReporterName = txt_ReporterName.Text.Trim(); model.Save(); Page.ClientScript.RegisterStartupScript(typeof(string), "", "alert('添加记录成功');window.location.href='AccidentRcdList.aspx'", true); } catch (Exception ex) { lab_Error.Text =ex.Message; } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_save_Click(object sender, EventArgs e) { AccidentRcd model = new AccidentRcd(); try { if (hid_id.Value != "") { model = AccidentRcd.Load(Convert.ToInt32(hid_id.Value)); } model.AccidentDate = Convert.ToDateTime(txt_AccidentDate.Text.Trim()); model.AccinenterName = txt_AccinenterName.Text.Trim(); model.ClsRoomCode = ddl_Workshop.SelectedValue; model.DevCode = txt_DevCode.Text.Trim(); model.DevUnitCode = txt_DevUnitCode.Text.Trim(); model.LeaderName = txt_LeaderName.Text.Trim(); model.Reason = txt_Reason.Text.Trim(); model.ReportDate = Convert.ToDateTime(txt_ReportDate.Text.Trim()); model.ReporterName = txt_ReporterName.Text.Trim(); model.Save(); hid_id.Value = ""; Page.ClientScript.RegisterStartupScript(typeof(string), "", "alert('修改记录成功');self.document.location.href='AccidentRcdList.aspx'", true); } catch (Exception ex) { lab_Error.Text = ex.Message; } }