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

            strSql.Append("update SchType set ");
            strSql.Append("SchTypeName=@SchTypeName,");
            strSql.Append("Stat=@Stat,");
            strSql.Append("NOTE=@NOTE");
            strSql.Append(" where SchTypeId=@SchTypeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SchTypeName", SqlDbType.VarChar,   20),
                new SqlParameter("@Stat",        SqlDbType.TinyInt,    1),
                new SqlParameter("@NOTE",        SqlDbType.NVarChar, 100),
                new SqlParameter("@SchTypeId",   SqlDbType.Int,        4),
                new SqlParameter("@SchTypeCode", SqlDbType.TinyInt, 1)
            };
            parameters[0].Value = model.SchTypeName;
            parameters[1].Value = model.Stat;
            parameters[2].Value = model.NOTE;
            parameters[3].Value = model.SchTypeId;
            parameters[4].Value = model.SchTypeCode;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.SchType DataRowToModel(DataRow row)
 {
     SchSystem.Model.SchType model = new SchSystem.Model.SchType();
     if (row != null)
     {
         if (row["SchTypeId"] != null && row["SchTypeId"].ToString() != "")
         {
             model.SchTypeId = int.Parse(row["SchTypeId"].ToString());
         }
         if (row["SchTypeCode"] != null && row["SchTypeCode"].ToString() != "")
         {
             model.SchTypeCode = int.Parse(row["SchTypeCode"].ToString());
         }
         if (row["SchTypeName"] != null)
         {
             model.SchTypeName = row["SchTypeName"].ToString();
         }
         if (row["Stat"] != null && row["Stat"].ToString() != "")
         {
             model.Stat = int.Parse(row["Stat"].ToString());
         }
         if (row["NOTE"] != null)
         {
             model.NOTE = row["NOTE"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string Action = context.Request.Form["Action"];

            if (Action == "Add")
            {
                int resulte;
                try
                {
                    SchSystem.Model.SchType st = new SchSystem.Model.SchType();
                    st.SchTypeCode = int.Parse(context.Request.Form["SchTypeCode"]);
                    st.SchTypeName = context.Request.Form["SchTypeName"];
                    st.Stat        = Convert.ToInt32(context.Request.Form["Stat"]);
                    st.NOTE        = context.Request.Form["NOTE"];

                    SchSystem.Bll.SchTypeBll stBll = new SchSystem.Bll.SchTypeBll();
                    resulte = stBll.Add(st);
                }
                catch (System.Data.SqlClient.SqlException e)
                {
                    throw e;
                }
                context.Response.Write(resulte);
            }
            else if (Action == "List")
            {
                SchSystem.Bll.SchTypeBll stBll = new SchSystem.Bll.SchTypeBll();
                //stBll.GetAllList();
                context.Response.Write(DatasetToJson(stBll.GetAllList()));
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SchSystem.Model.SchType model)
        {
            object obj;

            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into SchType(");
                strSql.Append("SchTypeCode,SchTypeName,Stat,NOTE)");
                strSql.Append(" values (");
                strSql.Append("@SchTypeCode,@SchTypeName,@Stat,@NOTE)");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@SchTypeCode", SqlDbType.TinyInt,   8),
                    new SqlParameter("@SchTypeName", SqlDbType.NVarChar, 50),
                    new SqlParameter("@Stat",        SqlDbType.TinyInt,   1),
                    new SqlParameter("@NOTE",        SqlDbType.NVarChar, 200)
                };


                parameters[0].Value = model.SchTypeCode;
                parameters[1].Value = model.SchTypeName;
                parameters[2].Value = model.Stat;
                parameters[3].Value = model.NOTE;


                obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            }
            catch (System.Data.SqlClient.SqlException e)
            {
                throw e;
            }
            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SchSystem.Model.SchType GetModel(int SchTypeId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 SchTypeId,SchTypeCode,SchTypeName,Stat,NOTE from SchType ");
            strSql.Append(" where SchTypeId=@SchTypeId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SchTypeId", SqlDbType.Int, 4)
            };
            parameters[0].Value = SchTypeId;

            SchSystem.Model.SchType model = new SchSystem.Model.SchType();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

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