public void UpdateDept(DeptEntity entity)
 {
     base.UseTran((tran) =>
     {
         DbCommand cmd = base.Database.GetStoredProcCommand("P_UpdateDept");
         base.Database.AddInParameter(cmd, "DeptId", DbType.Int32, entity.DeptId);
         base.Database.AddInParameter(cmd, "DeptNo", DbType.String, entity.DeptNo);
         base.Database.AddInParameter(cmd, "DeptName", DbType.String, entity.DeptName);
         base.Database.AddInParameter(cmd, "Remark", DbType.String, entity.Remark);
         base.Database.AddInParameter(cmd, "LastModifyId", DbType.String, entity.LastModifyId);
         base.Database.ExecuteNonQuery(cmd, tran);
     });
 }
 public int CreateDept(DeptEntity entity)
 {
     int entityid = 0;
     base.UseTran((tran) =>
     {
         DbCommand cmd = base.Database.GetStoredProcCommand("P_CreateDept");
         base.Database.AddOutParameter(cmd, "DeptId", DbType.Int32, 4);
         base.Database.AddInParameter(cmd, "DeptNo", DbType.String, entity.DeptNo);
         base.Database.AddInParameter(cmd, "DeptName", DbType.String, entity.DeptName);
         base.Database.AddInParameter(cmd, "Remark", DbType.String, entity.Remark);
         base.Database.AddInParameter(cmd, "PId", DbType.Int32, entity.PId);
         base.Database.AddInParameter(cmd, "CreateId", DbType.String, entity.CreateId);
         base.Database.ExecuteNonQuery(cmd, tran);
         entityid = (int)base.Database.GetParameterValue(cmd, "DeptId");
     });
     return entityid;
 }
 private static DeptEntity[] DataTableToEntitys(DataTable dt)
 {
     if (dt == null)
         return null;
     var results = new DeptEntity[dt.Rows.Count];
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         results[i] = DataRowToEntity(dt.Rows[i]);
     }
     return results;
 }
        private static DeptEntity DataRowToEntity(DataRow row)
        {
            if (row == null)
                return null;
            var result = new DeptEntity()
            {
                DeptId = (int)(row["DeptId"]),
                DeptNo = (string)(row["DeptNo"]),
                DeptName = (string)(row["DeptName"]),
                Remark = (string)(row["Remark"]),
                PId = (int)(row["PId"]),
                Level_Path = (string)(row["Level_Path"]),
                Level_Num = (int)(row["Level_Num"]),
                Level_Total = (int)(row["Level_Total"]),
                Level_Deep = (int)(row["Level_Deep"]),
                CreateId = (string)(row["CreateId"]),
                CreateDate = (DateTime)(row["CreateDate"]),
                LastModifyId = (string)(row["LastModifyId"]),
                LastModifyDate = (DateTime)(row["LastModifyDate"]),
                Deleted = (bool)(row["Deleted"]),

            };
            return result;
        }