コード例 #1
0
ファイル: SYS_Hospital.cs プロジェクト: kkwkk/ybyzt
 /// <summary>
 /// 由一行数据得到一个实体
 /// </summary>
 private Hi.Model.SYS_Hospital GetModel(DataRow r)
 {
     Hi.Model.SYS_Hospital model = new Hi.Model.SYS_Hospital();
     model.ID            = SqlHelper.GetInt(r["ID"]);
     model.HospitalCode  = SqlHelper.GetString(r["HospitalCode"]);
     model.HospitalName  = SqlHelper.GetString(r["HospitalName"]);
     model.HospitalLevel = SqlHelper.GetString(r["HospitalLevel"]);
     model.Province      = SqlHelper.GetString(r["Province"]);
     model.City          = SqlHelper.GetString(r["City"]);
     model.Area          = SqlHelper.GetString(r["Area"]);
     model.Address       = SqlHelper.GetString(r["Address"]);
     model.IsEnabled     = SqlHelper.GetBool(r["IsEnabled"]);
     model.SVdef1        = SqlHelper.GetString(r["SVdef1"]);
     model.SVdef2        = SqlHelper.GetString(r["SVdef2"]);
     model.SVdef3        = SqlHelper.GetString(r["SVdef3"]);
     model.CreateUser    = SqlHelper.GetString(r["CreateUser"]);
     model.CreateDate    = SqlHelper.GetDateTime(r["CreateDate"]);
     model.ts            = SqlHelper.GetDateTime(r["ts"]);
     model.dr            = SqlHelper.GetBool(r["dr"]);
     return(model);
 }
コード例 #2
0
ファイル: SYS_Hospital.cs プロジェクト: kkwkk/ybyzt
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Hi.Model.SYS_Hospital model)
        {
            model.ID = GetMaxId() + 1;
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [SYS_Hospital](");
            strSql.Append("[ID],[HospitalCode],[HospitalName],[HospitalLevel],[Province],[City],[Area],[Address],[IsEnabled],[SVdef1],[SVdef2],[SVdef3],[CreateUser],[CreateDate],[ts],[dr])");
            strSql.Append(" values (");
            strSql.Append("@ID,@HospitalCode,@HospitalName,@HospitalLevel,@Province,@City,@Area,@Address,@IsEnabled,@SVdef1,@SVdef2,@SVdef3,@CreateUser,@CreateDate,@ts,@dr)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",            SqlDbType.Int),
                new SqlParameter("@HospitalCode",  SqlDbType.NVarChar,   30),
                new SqlParameter("@HospitalName",  SqlDbType.NVarChar,   50),
                new SqlParameter("@HospitalLevel", SqlDbType.NVarChar,   30),
                new SqlParameter("@Province",      SqlDbType.NVarChar,   30),
                new SqlParameter("@City",          SqlDbType.NVarChar,   30),
                new SqlParameter("@Area",          SqlDbType.NVarChar,   50),
                new SqlParameter("@Address",       SqlDbType.NVarChar,  100),
                new SqlParameter("@IsEnabled",     SqlDbType.Bit),
                new SqlParameter("@SVdef1",        SqlDbType.NVarChar,  100),
                new SqlParameter("@SVdef2",        SqlDbType.NVarChar,  100),
                new SqlParameter("@SVdef3",        SqlDbType.NVarChar,  100),
                new SqlParameter("@CreateUser",    SqlDbType.Char,       36),
                new SqlParameter("@CreateDate",    SqlDbType.DateTime),
                new SqlParameter("@ts",            SqlDbType.DateTime),
                new SqlParameter("@dr",            SqlDbType.Bit)
            };
            parameters[0].Value = model.ID;

            if (model.HospitalCode != null)
            {
                parameters[1].Value = model.HospitalCode;
            }
            else
            {
                parameters[1].Value = DBNull.Value;
            }

            parameters[2].Value = model.HospitalName;

            if (model.HospitalLevel != null)
            {
                parameters[3].Value = model.HospitalLevel;
            }
            else
            {
                parameters[3].Value = DBNull.Value;
            }


            if (model.Province != null)
            {
                parameters[4].Value = model.Province;
            }
            else
            {
                parameters[4].Value = DBNull.Value;
            }


            if (model.City != null)
            {
                parameters[5].Value = model.City;
            }
            else
            {
                parameters[5].Value = DBNull.Value;
            }


            if (model.Area != null)
            {
                parameters[6].Value = model.Area;
            }
            else
            {
                parameters[6].Value = DBNull.Value;
            }


            if (model.Address != null)
            {
                parameters[7].Value = model.Address;
            }
            else
            {
                parameters[7].Value = DBNull.Value;
            }

            parameters[8].Value = model.IsEnabled;

            if (model.SVdef1 != null)
            {
                parameters[9].Value = model.SVdef1;
            }
            else
            {
                parameters[9].Value = DBNull.Value;
            }


            if (model.SVdef2 != null)
            {
                parameters[10].Value = model.SVdef2;
            }
            else
            {
                parameters[10].Value = DBNull.Value;
            }


            if (model.SVdef3 != null)
            {
                parameters[11].Value = model.SVdef3;
            }
            else
            {
                parameters[11].Value = DBNull.Value;
            }

            parameters[12].Value = model.CreateUser;
            parameters[13].Value = model.CreateDate;
            parameters[14].Value = model.ts;
            parameters[15].Value = model.dr;

            if (SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString(), parameters) > 0)
            {
                return(model.ID);
            }
            else
            {
                return(0);
            }
        }
コード例 #3
0
ファイル: SYS_Hospital.cs プロジェクト: kkwkk/ybyzt
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Hi.Model.SYS_Hospital model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [SYS_Hospital] set ");
            strSql.Append("[HospitalCode]=@HospitalCode,");
            strSql.Append("[HospitalName]=@HospitalName,");
            strSql.Append("[HospitalLevel]=@HospitalLevel,");
            strSql.Append("[Province]=@Province,");
            strSql.Append("[City]=@City,");
            strSql.Append("[Area]=@Area,");
            strSql.Append("[Address]=@Address,");
            strSql.Append("[IsEnabled]=@IsEnabled,");
            strSql.Append("[SVdef1]=@SVdef1,");
            strSql.Append("[SVdef2]=@SVdef2,");
            strSql.Append("[SVdef3]=@SVdef3,");
            strSql.Append("[CreateUser]=@CreateUser,");
            strSql.Append("[CreateDate]=@CreateDate,");
            strSql.Append("[ts]=@ts,");
            strSql.Append("[dr]=@dr");
            strSql.Append(" where [ID]=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",            SqlDbType.Int),
                new SqlParameter("@HospitalCode",  SqlDbType.NVarChar,   30),
                new SqlParameter("@HospitalName",  SqlDbType.NVarChar,   50),
                new SqlParameter("@HospitalLevel", SqlDbType.NVarChar,   30),
                new SqlParameter("@Province",      SqlDbType.NVarChar,   30),
                new SqlParameter("@City",          SqlDbType.NVarChar,   30),
                new SqlParameter("@Area",          SqlDbType.NVarChar,   50),
                new SqlParameter("@Address",       SqlDbType.NVarChar,  100),
                new SqlParameter("@IsEnabled",     SqlDbType.Bit),
                new SqlParameter("@SVdef1",        SqlDbType.NVarChar,  100),
                new SqlParameter("@SVdef2",        SqlDbType.NVarChar,  100),
                new SqlParameter("@SVdef3",        SqlDbType.NVarChar,  100),
                new SqlParameter("@CreateUser",    SqlDbType.Char,       36),
                new SqlParameter("@CreateDate",    SqlDbType.DateTime),
                new SqlParameter("@ts",            SqlDbType.DateTime),
                new SqlParameter("@dr",            SqlDbType.Bit)
            };
            parameters[0].Value = model.ID;

            if (model.HospitalCode != null)
            {
                parameters[1].Value = model.HospitalCode;
            }
            else
            {
                parameters[1].Value = DBNull.Value;
            }

            parameters[2].Value = model.HospitalName;

            if (model.HospitalLevel != null)
            {
                parameters[3].Value = model.HospitalLevel;
            }
            else
            {
                parameters[3].Value = DBNull.Value;
            }


            if (model.Province != null)
            {
                parameters[4].Value = model.Province;
            }
            else
            {
                parameters[4].Value = DBNull.Value;
            }


            if (model.City != null)
            {
                parameters[5].Value = model.City;
            }
            else
            {
                parameters[5].Value = DBNull.Value;
            }


            if (model.Area != null)
            {
                parameters[6].Value = model.Area;
            }
            else
            {
                parameters[6].Value = DBNull.Value;
            }


            if (model.Address != null)
            {
                parameters[7].Value = model.Address;
            }
            else
            {
                parameters[7].Value = DBNull.Value;
            }

            parameters[8].Value = model.IsEnabled;

            if (model.SVdef1 != null)
            {
                parameters[9].Value = model.SVdef1;
            }
            else
            {
                parameters[9].Value = DBNull.Value;
            }


            if (model.SVdef2 != null)
            {
                parameters[10].Value = model.SVdef2;
            }
            else
            {
                parameters[10].Value = DBNull.Value;
            }


            if (model.SVdef3 != null)
            {
                parameters[11].Value = model.SVdef3;
            }
            else
            {
                parameters[11].Value = DBNull.Value;
            }

            parameters[12].Value = model.CreateUser;
            parameters[13].Value = model.CreateDate;
            parameters[14].Value = model.ts;
            parameters[15].Value = model.dr;

            return(SqlHelper.ExecuteSql(SqlHelper.LocalSqlServer, strSql.ToString(), parameters) > 0);
        }