/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private WHSpecialType EntityGet() { WHSpecialType entity = new WHSpecialType(); entity.ID = HTDataID; return(entity); }
/// <summary> /// 修改 /// </summary> /// <param name="p_BE">要修改的实体</param> /// <param name="sqlTrans">事务类</param> public void RUpdate(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); WHSpecialType entity = (WHSpecialType)p_BE; string sql = string.Empty; sql = " SELECT 1 FROM Enum_WHSpecialType WHERE Code= " + SysString.ToDBString(entity.Code) + " AND ID<>" + entity.ID; if (sqlTrans.Fill(sql).Rows.Count != 0) { throw new Exception("该编码已经存在,请重新输入!"); } sql = " SELECT 1 FROM Enum_WHSpecialType WHERE Name= " + SysString.ToDBString(entity.Name) + " AND ID<>" + entity.ID; if (sqlTrans.Fill(sql).Rows.Count != 0) { throw new Exception("该名称已经存在,请重新输入!"); } WHSpecialTypeCtl control = new WHSpecialTypeCtl(sqlTrans); control.Update(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 删除 /// </summary> public override void EntityDelete() { WHSpecialTypeRule rule = new WHSpecialTypeRule(); WHSpecialType entity = EntityGet(); rule.RDelete(entity); }
/// <summary> /// 删除 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Delete(BaseEntity p_Entity) { try { WHSpecialType MasterEntity = (WHSpecialType)p_Entity; if (MasterEntity.ID == 0) { return(0); } //删除主表数据 string Sql = ""; Sql = "DELETE FROM Enum_WHSpecialType 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> /// <param name="p_BE">要新增的实体</param> /// <param name="sqlTrans">事务类</param> public void RAdd(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); WHSpecialType entity = (WHSpecialType)p_BE; string sql = string.Empty; sql = " SELECT 1 FROM Enum_WHSpecialType WHERE Code= " + SysString.ToDBString(entity.Code); if (sqlTrans.Fill(sql).Rows.Count != 0) { throw new Exception("该编码已经存在,请重新输入!"); } sql = " SELECT 1 FROM Enum_WHSpecialType WHERE Name= " + SysString.ToDBString(entity.Name); if (sqlTrans.Fill(sql).Rows.Count != 0) { throw new Exception("该名称已经存在,请重新输入!"); } WHSpecialTypeCtl control = new WHSpecialTypeCtl(sqlTrans); entity.ID = (int)EntityIDTable.GetID((long)SysEntity.Enum_WHSpecialType, sqlTrans); control.AddNew(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 新增 /// </summary> public override int EntityAdd() { WHSpecialTypeRule rule = new WHSpecialTypeRule(); WHSpecialType entity = EntityGet(); rule.RAdd(entity); return(entity.ID); }
/// <summary> /// 获得实体 /// </summary> /// <returns></returns> private WHSpecialType EntityGet() { WHSpecialType entity = new WHSpecialType(); entity.ID = HTDataID; entity.SelectByID(); entity.Code = txtCode.Text.Trim(); entity.Name = txtName.Text.Trim(); entity.Remark = txtRemark.Text.Trim(); return(entity); }
/// <summary> /// 新增 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int AddNew(BaseEntity p_Entity) { try { WHSpecialType MasterEntity = (WHSpecialType)p_Entity; if (MasterEntity.ID == 0) { return(0); } //新增主表数据 StringBuilder MasterField = new StringBuilder(); StringBuilder MasterValue = new StringBuilder(); MasterField.Append("INSERT INTO Enum_WHSpecialType("); MasterValue.Append(" VALUES("); MasterField.Append("ID" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.ID) + ","); MasterField.Append("Code" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Code) + ","); MasterField.Append("Name" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Name) + ","); MasterField.Append("Remark" + ","); MasterValue.Append(SysString.ToDBString(MasterEntity.Remark) + ","); 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); } }
/// <summary> /// 设置 /// </summary> public override void EntitySet() { WHSpecialType entity = new WHSpecialType(); entity.ID = HTDataID; bool findFlag = entity.SelectByID(); txtCode.Text = entity.Code.ToString(); txtName.Text = entity.Name.ToString(); txtRemark.Text = entity.Remark.ToString(); if (!findFlag) { } }
/// <summary> /// 删除 /// </summary> /// <param name="p_BE">要删除的实体</param> /// <param name="sqlTrans">事务类</param> public void RDelete(BaseEntity p_BE, IDBTransAccess sqlTrans) { try { this.CheckCorrect(p_BE); WHSpecialType entity = (WHSpecialType)p_BE; WHSpecialTypeCtl control = new WHSpecialTypeCtl(sqlTrans); control.Delete(entity); } catch (BaseException) { throw; } catch (Exception E) { throw new BaseException(E.Message); } }
/// <summary> /// 修改 /// </summary> /// <param name="p_Entity">实体类</param> /// <returns>操作影响的记录行数</returns> public override int Update(BaseEntity p_Entity) { try { WHSpecialType MasterEntity = (WHSpecialType)p_Entity; if (MasterEntity.ID == 0) { return(0); } //更新主表数据 StringBuilder UpdateBuilder = new StringBuilder(); UpdateBuilder.Append("UPDATE Enum_WHSpecialType SET "); UpdateBuilder.Append(" ID=" + SysString.ToDBString(MasterEntity.ID) + ","); UpdateBuilder.Append(" Code=" + SysString.ToDBString(MasterEntity.Code) + ","); UpdateBuilder.Append(" Name=" + SysString.ToDBString(MasterEntity.Name) + ","); UpdateBuilder.Append(" Remark=" + SysString.ToDBString(MasterEntity.Remark) + ","); 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> /// <param name="p_BE"></param> private void CheckCorrect(BaseEntity p_BE) { WHSpecialType entity = (WHSpecialType)p_BE; }