/// <summary>
 /// 根据主键删除调查组人员
 /// </summary>
 /// <param name="accidentReportOtherItemId"></param>
 public static void DeleteAccidentReportOtherItemById(string accidentReportOtherItemId)
 {
     Model.SUBHSSEDB db = Funs.DB;
     Model.Accident_AccidentReportOtherItem item = db.Accident_AccidentReportOtherItem.FirstOrDefault(e => e.AccidentReportOtherItemId == accidentReportOtherItemId);
     if (item != null)
     {
         db.Accident_AccidentReportOtherItem.DeleteOnSubmit(item);
         db.SubmitChanges();
     }
 }
 /// <summary>
 /// 修改调查组人员
 /// </summary>
 /// <param name="accidentReportOtherItem"></param>
 public static void UpdateAccidentReportOtherItem(Model.Accident_AccidentReportOtherItem accidentReportOtherItem)
 {
     Model.SUBHSSEDB db = Funs.DB;
     Model.Accident_AccidentReportOtherItem newAccidentReportOtherItem = db.Accident_AccidentReportOtherItem.FirstOrDefault(e => e.AccidentReportOtherItemId == accidentReportOtherItem.AccidentReportOtherItemId);
     if (newAccidentReportOtherItem != null)
     {
         newAccidentReportOtherItem.AccidentReportOtherId = accidentReportOtherItem.AccidentReportOtherId;
         newAccidentReportOtherItem.UnitId     = accidentReportOtherItem.UnitId;
         newAccidentReportOtherItem.PersonId   = accidentReportOtherItem.PersonId;
         newAccidentReportOtherItem.PositionId = accidentReportOtherItem.PositionId;
         db.SubmitChanges();
     }
 }
 /// <summary>
 /// 添加调查组人员
 /// </summary>
 /// <param name="accidentReportOtherItem"></param>
 public static void AddAccidentReportOtherItem(Model.Accident_AccidentReportOtherItem accidentReportOtherItem)
 {
     Model.SUBHSSEDB db = Funs.DB;
     Model.Accident_AccidentReportOtherItem newAccidentReportOtherItem = new Model.Accident_AccidentReportOtherItem
     {
         AccidentReportOtherItemId = accidentReportOtherItem.AccidentReportOtherItemId,
         AccidentReportOtherId     = accidentReportOtherItem.AccidentReportOtherId,
         UnitId     = accidentReportOtherItem.UnitId,
         PersonId   = accidentReportOtherItem.PersonId,
         PositionId = accidentReportOtherItem.PositionId
     };
     db.Accident_AccidentReportOtherItem.InsertOnSubmit(newAccidentReportOtherItem);
     db.SubmitChanges();
 }
 /// <summary>
 /// 加载页面
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         this.btnClose.OnClientClick   = ActiveWindow.GetHideReference();
         this.drpUnitId.DataValueField = "UnitId";
         this.drpUnitId.DataTextField  = "UnitName";
         this.drpUnitId.DataSource     = BLL.UnitService.GetUnitByProjectIdList(this.CurrUser.LoginProjectId);
         this.drpUnitId.DataBind();
         Funs.FineUIPleaseSelect(this.drpUnitId);
         this.drpPersonId.DataValueField = "PersonId";
         this.drpPersonId.DataTextField  = "PersonName";
         this.drpPersonId.DataSource     = BLL.PersonService.GetPersonList(this.CurrUser.LoginProjectId);
         this.drpPersonId.DataBind();
         Funs.FineUIPleaseSelect(this.drpPersonId);
         this.AccidentReportOtherId     = Request.Params["AccidentReportOtherId"];
         this.AccidentReportOtherItemId = Request.Params["AccidentReportOtherItemId"];
         if (!string.IsNullOrEmpty(this.AccidentReportOtherItemId))
         {
             Model.Accident_AccidentReportOtherItem accidentReportOtherItem = BLL.AccidentReportOtherItemService.GetAccidentReportOtherItemById(this.AccidentReportOtherItemId);
             if (accidentReportOtherItem != null)
             {
                 this.AccidentReportOtherId = accidentReportOtherItem.AccidentReportOtherId;
                 if (!string.IsNullOrEmpty(accidentReportOtherItem.UnitId))
                 {
                     this.drpUnitId.SelectedValue = accidentReportOtherItem.UnitId;
                 }
                 if (!string.IsNullOrEmpty(accidentReportOtherItem.PersonId))
                 {
                     this.drpPersonId.SelectedValue = accidentReportOtherItem.PersonId;
                 }
                 if (!string.IsNullOrEmpty(accidentReportOtherItem.PositionId))
                 {
                     this.hdPositionId.Text = accidentReportOtherItem.PositionId;
                     var position = BLL.PositionService.GetPositionById(this.hdPositionId.Text);
                     if (position != null)
                     {
                         this.txtPositionName.Text = position.PositionName;
                     }
                 }
             }
         }
     }
 }
 /// <summary>
 /// 保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Model.Accident_AccidentReportOtherItem accidentReportOtherItem = new Model.Accident_AccidentReportOtherItem
     {
         AccidentReportOtherId = this.AccidentReportOtherId
     };
     if (this.drpUnitId.SelectedValue != BLL.Const._Null)
     {
         accidentReportOtherItem.UnitId = this.drpUnitId.SelectedValue;
     }
     else
     {
         Alert.ShowInTop("请选择单位!", MessageBoxIcon.Warning);
         return;
     }
     if (this.drpPersonId.SelectedValue != BLL.Const._Null)
     {
         accidentReportOtherItem.PersonId = this.drpPersonId.SelectedValue;
     }
     else
     {
         Alert.ShowInTop("请选择姓名!", MessageBoxIcon.Warning);
         return;
     }
     if (!string.IsNullOrEmpty(this.hdPositionId.Text))
     {
         accidentReportOtherItem.PositionId = this.hdPositionId.Text;
     }
     if (!string.IsNullOrEmpty(this.AccidentReportOtherItemId))
     {
         accidentReportOtherItem.AccidentReportOtherItemId = this.AccidentReportOtherItemId;
         BLL.AccidentReportOtherItemService.UpdateAccidentReportOtherItem(accidentReportOtherItem);
     }
     else
     {
         this.AccidentReportOtherItemId = SQLHelper.GetNewID(typeof(Model.Accident_AccidentReportOtherItem));
         accidentReportOtherItem.AccidentReportOtherItemId = this.AccidentReportOtherItemId;
         BLL.AccidentReportOtherItemService.AddAccidentReportOtherItem(accidentReportOtherItem);
     }
     PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
 }