Ejemplo n.º 1
0
 public int AddOrgan(Organ_Detail model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("insert into [dbo].[Organ_Detail] ([Title],[ParentId],[OType],[Remark],[Delflag],[CreateDate],[PartitionId],[StudyRegionId],[OutSourceId])");
     sql.Append(" values (@Title,@ParentId,@OType,@Remark,@Delflag,@CreateDate,@PartitionId,@StudyRegionId,@OutSourceId)");
     sql.Append(" set @Id=@@IDENTITY");
     SqlParameter[] cmdParams = new SqlParameter[]{
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id, Direction = ParameterDirection.Output },
         new SqlParameter("@Title", SqlDbType.VarChar, 200) { Value = model.Title },
         new SqlParameter("@ParentId", SqlDbType.Int, 4) { Value = model.ParentId },
         new SqlParameter("@OType", SqlDbType.Int, 4) { Value = model.OType },
         new SqlParameter("@Remark", SqlDbType.VarChar, 50) { Value = model.Remark },
         new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag },
         new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate },
         new SqlParameter("@PartitionId", SqlDbType.Int, 4) { Value = model.PartitionId },
         new SqlParameter("@StudyRegionId", SqlDbType.Int, 4) { Value = model.StudyRegionId },
         new SqlParameter("@OutSourceId", SqlDbType.Int, 4) { Value = model.OutSourceId }
     };
     int result = Convert.ToInt32(MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams));
     model.Id = Convert.ToInt32(cmdParams[0].Value);
     return result;
 }
Ejemplo n.º 2
0
        private Organ_Detail ToOrgan(schoolcode model)
        {
            Organ_Detail organ = new Organ_Detail();
            organ.Title = model.classname;
            if (!string.IsNullOrEmpty(model.DistrictID))
                organ.ParentId = Convert.ToInt32(model.DistrictID);
            organ.OType = 2;
            organ.CreateDate = DateTime.Now;
            organ.PartitionId = 1;
            if (!string.IsNullOrEmpty(model.XueQuID))
                organ.StudyRegionId = Convert.ToInt32(model.XueQuID);
            if (!string.IsNullOrEmpty(model.ID))
                organ.OutSourceId = Convert.ToInt32(model.ID);

            return organ;
        }
Ejemplo n.º 3
0
 private void ConvertToModel(IDataReader reader, Organ_Detail model)
 {
     if (reader["Id"] != DBNull.Value)
         model.Id = Convert.ToInt32(reader["Id"]);
     if (reader["Title"] != DBNull.Value)
         model.Title = reader["Title"].ToString();
     if (reader["ParentId"] != DBNull.Value)
         model.ParentId = Convert.ToInt32(reader["ParentId"]);
     if (reader["OType"] != DBNull.Value)
         model.OType = Convert.ToInt32(reader["OType"]);
     if (reader["Remark"] != DBNull.Value)
         model.Remark = reader["Remark"].ToString();
     if (reader["Delflag"] != DBNull.Value)
         model.Delflag = Convert.ToBoolean(reader["Delflag"]);
     if (reader["CreateDate"] != DBNull.Value)
         model.CreateDate = Convert.ToDateTime(reader["CreateDate"]);
     if (reader["PartitionId"] != DBNull.Value)
         model.PartitionId = Convert.ToInt32(reader["PartitionId"]);
     if (reader["StudyRegionId"] != DBNull.Value)
         model.StudyRegionId = Convert.ToInt32(reader["StudyRegionId"]);
     if (reader["OutSourceId"] != DBNull.Value)
         model.OutSourceId = Convert.ToInt32(reader["OutSourceId"]);
 }
Ejemplo n.º 4
0
 public int UpdateOrgan(Organ_Detail model)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("update [dbo].[Organ_Detail] set ");
     sql.Append("[Title]=@Title,[ParentId]=@ParentId,[OType]=@OType,[Remark]=@Remark,[Delflag]=@Delflag,[CreateDate]=@CreateDate,[PartitionId]=@PartitionId,[StudyRegionId]=@StudyRegionId,[OutSourceId]=@OutSourceId");
     sql.Append(" where [Id]=@Id");
     SqlParameter[] cmdParams = new SqlParameter[] {
         new SqlParameter("@Id", SqlDbType.Int, 4) { Value = model.Id },
         new SqlParameter("@Title", SqlDbType.VarChar, 200) { Value = model.Title },
         new SqlParameter("@ParentId", SqlDbType.Int, 4) { Value = model.ParentId },
         new SqlParameter("@OType", SqlDbType.Int, 4) { Value = model.OType },
         new SqlParameter("@Remark", SqlDbType.VarChar, 50) { Value = model.Remark },
         new SqlParameter("@Delflag", SqlDbType.Bit, 1) { Value = model.Delflag },
         new SqlParameter("@CreateDate", SqlDbType.DateTime, 8) { Value = model.CreateDate },
         new SqlParameter("@PartitionId", SqlDbType.Int, 4) { Value = model.PartitionId },
         new SqlParameter("@StudyRegionId", SqlDbType.Int, 4) { Value = model.StudyRegionId },
         new SqlParameter("@OutSourceId", SqlDbType.Int, 4) { Value = model.OutSourceId }
     };
     return MSEntLibSqlHelper.ExecuteNonQueryBySql(sql.ToString(), cmdParams);
 }
Ejemplo n.º 5
0
 public Organ_Detail GetOrganByOutId(int outId)
 {
     string sql = "select * from [dbo].[Organ_Detail] where [OutSourceId]=@OutId and Delflag=0";
     SqlParameter[] cmdParams = new SqlParameter[]{
         new SqlParameter("@OutId", SqlDbType.Int, 4) { Value = outId }
     };
     using (IDataReader reader = MSEntLibSqlHelper.ExecuteDataReaderBySql(sql, cmdParams))
     {
         if (reader.Read())
         {
             Organ_Detail model = new Organ_Detail();
             ConvertToModel(reader, model);
             return model;
         }
         else
         {
             return null;
         }
     }
 }
Ejemplo n.º 6
0
 public bool AddOrgan(Organ_Detail model)
 {
     return dal.AddOrgan(model) > 0;
 }
Ejemplo n.º 7
0
 public bool UpdateOrgan(Organ_Detail model)
 {
     return dal.UpdateOrgan(model) > 0;
 }