Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(university.Model.CCOM.Major model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Major set ");
            strSql.Append("Major_require=@Major_require,");
            strSql.Append("Major_academic=@Major_academic,");
            strSql.Append("Major_reference=@Major_reference,");
            strSql.Append("Agency_id=@Agency_id,");
            strSql.Append("Period_id=@Period_id,");
            strSql.Append("Major_remark=@Major_remark");
            strSql.Append(" where Major_id=@Major_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Major_require",   SqlDbType.Text),
                new SqlParameter("@Major_academic",  SqlDbType.VarChar, 64),
                new SqlParameter("@Major_reference", SqlDbType.Text),
                new SqlParameter("@Agency_id",       SqlDbType.Int,      4),
                new SqlParameter("@Period_id",       SqlDbType.Int,      4),
                new SqlParameter("@Major_remark",    SqlDbType.Text),
                new SqlParameter("@Major_id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Major_require;
            parameters[1].Value = model.Major_academic;
            parameters[2].Value = model.Major_reference;
            parameters[3].Value = model.Agency_id;
            parameters[4].Value = model.Period_id;
            parameters[5].Value = model.Major_remark;
            parameters[6].Value = model.Major_id;

            int rows = DBSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.Major GetModel(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Major_id,Major_require,Major_academic,Major_reference,Agency_id,Period_id,Major_remark from Major ");
            strSql.Append(" where " + strWhere);


            university.Model.CCOM.Major model = new university.Model.CCOM.Major();
            DataSet ds = DBSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Major_id"].ToString() != "")
                {
                    model.Major_id = int.Parse(ds.Tables[0].Rows[0]["Major_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Major_require"].ToString() != "")
                {
                    model.Major_require = ds.Tables[0].Rows[0]["Major_require"].ToString();
                }
                model.Major_academic  = ds.Tables[0].Rows[0]["Major_academic"].ToString();
                model.Major_reference = ds.Tables[0].Rows[0]["Major_reference"].ToString();
                if (ds.Tables[0].Rows[0]["Agency_id"].ToString() != "")
                {
                    model.Agency_id = int.Parse(ds.Tables[0].Rows[0]["Agency_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Period_id"].ToString() != "")
                {
                    model.Period_id = int.Parse(ds.Tables[0].Rows[0]["Period_id"].ToString());
                }
                model.Major_remark = ds.Tables[0].Rows[0]["Major_remark"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(university.Model.CCOM.Major model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Major(");
            strSql.Append("Major_require,Major_academic,Major_reference,Agency_id,Period_id,Major_remark)");
            strSql.Append(" values (");
            strSql.Append("@Major_require,@Major_academic,@Major_reference,@Agency_id,@Period_id,@Major_remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Major_require",   SqlDbType.Text),
                new SqlParameter("@Major_academic",  SqlDbType.VarChar, 64),
                new SqlParameter("@Major_reference", SqlDbType.Text),
                new SqlParameter("@Agency_id",       SqlDbType.Int,      4),
                new SqlParameter("@Period_id",       SqlDbType.Int,      4),
                new SqlParameter("@Major_remark",    SqlDbType.Text)
            };
            parameters[0].Value = model.Major_require;
            parameters[1].Value = model.Major_academic;
            parameters[2].Value = model.Major_reference;
            parameters[3].Value = model.Agency_id;
            parameters[4].Value = model.Period_id;
            parameters[5].Value = model.Major_remark;

            object obj = DBSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public university.Model.CCOM.Major DataRowToModel(DataRow row)
 {
     university.Model.CCOM.Major model = new university.Model.CCOM.Major();
     if (row != null)
     {
         if (row["Major_id"] != null && row["Major_id"].ToString() != "")
         {
             model.Major_id = int.Parse(row["Major_id"].ToString());
         }
         if (row["Major_require"] != null)
         {
             model.Major_require = row["Major_require"].ToString();
         }
         if (row["Major_academic"] != null)
         {
             model.Major_academic = row["Major_academic"].ToString();
         }
         if (row["Major_reference"] != null)
         {
             model.Major_reference = row["Major_reference"].ToString();
         }
         if (row["Agency_id"] != null && row["Agency_id"].ToString() != "")
         {
             model.Agency_id = int.Parse(row["Agency_id"].ToString());
         }
         if (row["Period_id"] != null && row["Period_id"].ToString() != "")
         {
             model.Period_id = int.Parse(row["Period_id"].ToString());
         }
         if (row["Major_remark"] != null)
         {
             model.Major_remark = row["Major_remark"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public university.Model.CCOM.Major GetModel(int Major_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Major_id,Major_require,Major_academic,Major_reference,Agency_id,Period_id,Major_remark from Major ");
            strSql.Append(" where Major_id=@Major_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Major_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Major_id;

            university.Model.CCOM.Major model = new university.Model.CCOM.Major();
            DataSet ds = DBSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }