Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SchSystem.Model.SchPerSubMat model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SchPerSubMat set ");
            strSql.Append("PerCode=@PerCode,");
            strSql.Append("SubCode=@SubCode,");
            strSql.Append("MaterCode=@MaterCode,");
            strSql.Append("SchId=@SchId");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PerCode",   SqlDbType.VarChar,  10),
                new SqlParameter("@SubCode",   SqlDbType.VarChar,  10),
                new SqlParameter("@MaterCode", SqlDbType.VarChar, 100),
                new SqlParameter("@SchId",     SqlDbType.Int,       4),
                new SqlParameter("@AutoId",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.PerCode;
            parameters[1].Value = model.SubCode;
            parameters[2].Value = model.MaterCode;
            parameters[3].Value = model.SchId;
            parameters[4].Value = model.AutoId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SchSystem.Model.SchPerSubMat model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SchPerSubMat(");
            strSql.Append("PerCode,SubCode,MaterCode,SchId)");
            strSql.Append(" values (");
            strSql.Append("@PerCode,@SubCode,@MaterCode,@SchId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PerCode",   SqlDbType.VarChar,  10),
                new SqlParameter("@SubCode",   SqlDbType.VarChar,  10),
                new SqlParameter("@MaterCode", SqlDbType.VarChar, 100),
                new SqlParameter("@SchId",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.PerCode;
            parameters[1].Value = model.SubCode;
            parameters[2].Value = model.MaterCode;
            parameters[3].Value = model.SchId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SchSystem.Model.SchPerSubMat DataRowToModel(DataRow row)
 {
     SchSystem.Model.SchPerSubMat model = new SchSystem.Model.SchPerSubMat();
     if (row != null)
     {
         if (row["AutoId"] != null && row["AutoId"].ToString() != "")
         {
             model.AutoId = int.Parse(row["AutoId"].ToString());
         }
         if (row["PerCode"] != null)
         {
             model.PerCode = row["PerCode"].ToString();
         }
         if (row["SubCode"] != null)
         {
             model.SubCode = row["SubCode"].ToString();
         }
         if (row["MaterCode"] != null)
         {
             model.MaterCode = row["MaterCode"].ToString();
         }
         if (row["SchId"] != null && row["SchId"].ToString() != "")
         {
             model.SchId = int.Parse(row["SchId"].ToString());
         }
     }
     return(model);
 }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SchSystem.Model.SchPerSubMat GetModel(int AutoId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 AutoId,PerCode,SubCode,MaterCode,SchId from SchPerSubMat ");
            strSql.Append(" where AutoId=@AutoId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@AutoId", SqlDbType.Int, 4)
            };
            parameters[0].Value = AutoId;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
        /// <summary>
        /// 资料科目及教版
        /// </summary>
        /// <param name="schid"></param>
        /// <param name="kinderstr"></param>
        /// <param name="primarystr"></param>
        /// <param name="juniorstr"></param>
        /// <param name="highstr"></param>
        public static void dataSubMat(int schid, string kinderstr, string primarystr, string juniorstr, string highstr)
        {
            SchSystem.BLL.SchPerSubMat   spsmBll   = new SchSystem.BLL.SchPerSubMat();
            SchSystem.Model.SchPerSubMat spsmModel = new SchSystem.Model.SchPerSubMat();
            bool resbool = spsmBll.Exists(schid); //判断原来是否存在

            if (resbool)                          //存在
            {
                spsmBll.Delete(schid);            //删除
            }
            if (kinderstr != "")
            {
                string[] kinderstrarr = kinderstr.Split('|');
                for (int i = 0; i < kinderstrarr.Length; i++)
                {
                    string[] kinderarr = kinderstrarr[i].Split(',');
                    spsmModel.SchId     = schid;
                    spsmModel.PerCode   = kinderarr[0];
                    spsmModel.SubCode   = kinderarr[1];
                    spsmModel.MaterCode = kinderarr[2];
                    spsmBll.Add(spsmModel);
                }
            }
            if (primarystr != "")
            {
                string[] primarystrarr = primarystr.Split('|');
                for (int i = 0; i < primarystrarr.Length; i++)
                {
                    string[] primaryarr = primarystrarr[i].Split(',');
                    spsmModel.SchId     = schid;
                    spsmModel.PerCode   = primaryarr[0];
                    spsmModel.SubCode   = primaryarr[1];
                    spsmModel.MaterCode = primaryarr[2];
                    spsmBll.Add(spsmModel);
                }
            }
            if (juniorstr != "")
            {
                string[] juniorstrarr = juniorstr.Split('|');
                for (int i = 0; i < juniorstrarr.Length; i++)
                {
                    string[] juniorarr = juniorstrarr[i].Split(',');
                    spsmModel.SchId     = schid;
                    spsmModel.PerCode   = juniorarr[0];
                    spsmModel.SubCode   = juniorarr[1];
                    spsmModel.MaterCode = juniorarr[2];
                    spsmBll.Add(spsmModel);
                }
            }
            if (highstr != "")
            {
                string[] highstrarr = highstr.Split('|');
                for (int i = 0; i < highstrarr.Length; i++)
                {
                    string[] higharr = highstrarr[i].Split(',');
                    spsmModel.SchId     = schid;
                    spsmModel.PerCode   = higharr[0];
                    spsmModel.SubCode   = higharr[1];
                    spsmModel.MaterCode = higharr[2];
                    spsmBll.Add(spsmModel);
                }
            }
        }