/// <summary> /// 修改 /// </summary> /// <param name="p_BE">要修改的实体</param> /// <param name="sqlTrans">事务类</param> public void RUpdate(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); GZNote entity = (GZNote)p_BE; GZNoteCtl control = new GZNoteCtl(sqlTrans); control.Update(entity); string sql = "DELETE Data_GZNoteDts WHERE MainID=" + SysString.ToDBString(entity.ID); sqlTrans.ExecuteNonQuery(sql); for (int i = 0; i < p_BE2.Length; i++) { GZNoteDtsRule rule = new GZNoteDtsRule(); GZNoteDts entityDts = (GZNoteDts)p_BE2[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; rule.RAdd(entityDts, sqlTrans); } } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { GZNote MasterEntity = (GZNote)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Data_GZNote WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(Sql); } else { AffectedRows = sqlTrans.ExecuteNonQuery(Sql); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBDelete), E); } }
/// <summary> /// 删除 /// </summary> public override void EntityDelete() { GZNoteRule rule = new GZNoteRule(); GZNote entity = EntityGet(); rule.RDelete(entity); }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private GZNote EntityGet() { GZNote entity = new GZNote(); entity.ID = HTDataID; return(entity); }
/// <summary> /// 修改 /// </summary> public override void EntityUpdate() { GZNoteRule rule = new GZNoteRule(); GZNote entity = EntityGet(); GZNoteDts[] entitydts = EntityDtsGet(); entity.SubmitFlag = this.HTSubmitFlagUpdateGet(); rule.RUpdate(entity, entitydts); }
/// <summary> /// 修改 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { GZNote MasterEntity = (GZNote)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Data_GZNote SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" FormNo=" + SysString.ToDBString(MasterEntity.FormNo) + ","); UpdateBuilder.Append(" OPID=" + SysString.ToDBString(MasterEntity.OPID) + ","); UpdateBuilder.Append(" OPName=" + SysString.ToDBString(MasterEntity.OPName) + ","); if (MasterEntity.FormDate != SystemConfiguration.DateTimeDefaultValue) { UpdateBuilder.Append(" FormDate=" + SysString.ToDBString(MasterEntity.FormDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { UpdateBuilder.Append(" FormDate=null,"); } UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); UpdateBuilder.Append(" SubmitFlag=" + SysString.ToDBString(MasterEntity.SubmitFlag) + ","); UpdateBuilder.Append(" DelFlag=" + SysString.ToDBString(MasterEntity.DelFlag)); UpdateBuilder.Append(" WHERE " + "ID=" + SysString.ToDBString(MasterEntity.ID)); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(UpdateBuilder.ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(UpdateBuilder.ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBUpdate), E); } }
/// <summary> /// 新增 /// </summary> public override int EntityAdd() { GZNoteRule rule = new GZNoteRule(); GZNote entity = EntityGet(); GZNoteDts[] entitydts = EntityDtsGet(); entity.SubmitFlag = this.HTSubmitFlagInsertGet(); rule.RAdd(entity, entitydts); return(entity.ID); }
/// <summary> /// 检验字段值是否已存在 /// </summary> /// <param name="p_TableName">表名</param> /// <param name="p_FieldName">字段名</param> /// <param name="p_FieldValue">字段值</param> /// <param name="p_KeyField">主键(只考虑主键为ID的情况)</param> /// <param name="p_KeyValue">主键值</param> /// <param name="p_sqlTrans"></param> /// <returns></returns> private bool CheckFieldValueIsExist(BaseEntity p_BE, string p_FieldName, string p_FieldValue, IDBTransAccess p_sqlTrans) { GZNote entity = (GZNote)p_BE; bool ret = false; string sql = string.Format(" SELECT {0} FROM {1} WHERE 1=1 AND {0}={2} AND {3}<>{4}", p_FieldName, GZNote.TableName, SysString.ToDBString(p_FieldValue), "ID", entity.ID); DataTable dt = p_sqlTrans.Fill(sql); if (dt.Rows.Count != 0) { ret = true; } return(ret); }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private GZNote EntityGet() { GZNote entity = new GZNote(); entity.ID = HTDataID; entity.SelectByID(); entity.FormNo = txtFormNo.Text.Trim(); entity.OPID = FParamConfig.LoginID; entity.OPName = txtOPName.Text.Trim(); entity.FormDate = txtFormDate.DateTime.Date; entity.Remark = txtRemark.Text.Trim(); return(entity); }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); GZNote entity = (GZNote)p_BE; GZNoteCtl control = new GZNoteCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, BaseEntity[] p_BE2, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); GZNote entity = (GZNote)p_BE; GZNoteCtl control = new GZNoteCtl(sqlTrans); string sql = "SELECT FormNo FROM Data_GZNote WHERE FormNo=" + SysString.ToDBString(entity.FormNo); DataTable dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("报告编号已存在,请重新生成"); } sql = "SELECT * FROM Data_GZNote WHERE FormDate=" + SysString.ToDBString(entity.FormDate); sql += " AND OPID=" + SysString.ToDBString(entity.OPID); dt = sqlTrans.Fill(sql); if (dt.Rows.Count > 0) { throw new BaseException("该时间的工作日报已存在,请检查"); } entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_GZNote, sqlTrans); control.AddNew(entity); for (int i = 0; i < p_BE2.Length; i++) { GZNoteDtsRule rule = new GZNoteDtsRule(); GZNoteDts entityDts = (GZNoteDts)p_BE2[i]; entityDts.MainID = entity.ID; entityDts.Seq = i + 1; rule.RAdd(entityDts, sqlTrans); } FormNoControlRule rulest = new FormNoControlRule(); rulest.RAddSort((int)FormNoControlEnum.日报编号, sqlTrans); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增(传入事务处理) /// </summary> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); GZNote entity = (GZNote)p_BE; GZNoteCtl control = new GZNoteCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Data_GZNote, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 设置 /// </summary> public override void EntitySet() { GZNote entity = new GZNote(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); txtFormNo.Text = entity.FormNo.ToString(); txtOPName.Text = entity.OPName.ToString(); txtFormDate.DateTime = entity.FormDate; txtRemark.Text = entity.Remark.ToString(); HTDataSubmitFlag = entity.SubmitFlag; HTDataDelFlag = entity.DelFlag; if (!findFlag) { } BindGridDts(); }
/// <summary> /// 检查将要操作的数据是否符合业务规则 /// </summary> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { GZNote entity = (GZNote)p_BE; }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { GZNote MasterEntity = (GZNote)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Data_GZNote("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("FormNo" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.FormNo) + ","); MasterField.Append("OPID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.OPID) + ","); MasterField.Append("OPName" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.OPName) + ","); MasterField.Append("FormDate" + ","); if (MasterEntity.FormDate != SystemConfiguration.DateTimeDefaultValue) { MasterValue.Append(SysString.ToDBString(MasterEntity.FormDate.ToString("yyyy-MM-dd HH:mm:ss")) + ","); } else { MasterValue.Append("null,"); } MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); MasterField.Append("SubmitFlag" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.SubmitFlag) + ","); MasterField.Append("DelFlag" + ")"); MasterValue.Append(SysString.ToDBString(MasterEntity.DelFlag) + ")"); //执行 int AffectedRows = 0; if (!this.sqlTransFlag) { AffectedRows = this.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } else { AffectedRows = sqlTrans.ExecuteNonQuery(MasterField.Append(MasterValue.ToString()).ToString()); } return(AffectedRows); } catch (BaseException E) { throw new BaseException(E.Message, E); } catch (Exception E) { throw new BaseException(FrameWorkMessage.GetAlertMessage((int)Message.CommonDBInsert), E); } }