コード例 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.BaseDictionaryDetail GetModel(int CatgID, string caption)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Idx,CatgID,ParentCatgID,Caption,Value,Value1,Value2,Value3 from BaseDictionaryDetail ");
            strSql.Append(" where CatgID=@CatgID and Caption=@caption ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CatgID",  SqlDbType.Int,      4),
                new SqlParameter("@caption", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = CatgID;
            parameters[1].Value = caption;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.BaseDictionaryDetail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BaseDictionaryDetail set ");
            strSql.Append("Idx=@Idx,");
            strSql.Append("ParentCatgID=@ParentCatgID,");
            strSql.Append("Caption=@Caption,");
            strSql.Append("Value1=@Value1,");
            strSql.Append("Value2=@Value2,");
            strSql.Append("Value3=@Value3");
            strSql.Append(" where CatgID=@CatgID and Value=@Value ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Idx",          SqlDbType.Int,       4),
                new SqlParameter("@ParentCatgID", SqlDbType.Int,       4),
                new SqlParameter("@Caption",      SqlDbType.NVarChar, 50),
                new SqlParameter("@Value1",       SqlDbType.NVarChar, 50),
                new SqlParameter("@Value2",       SqlDbType.NVarChar, 50),
                new SqlParameter("@Value3",       SqlDbType.NVarChar, 50),
                new SqlParameter("@CatgID",       SqlDbType.Int,       4),
                new SqlParameter("@Value",        SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Idx;
            parameters[1].Value = model.ParentCatgID;
            parameters[2].Value = model.Caption;
            parameters[3].Value = model.Value1;
            parameters[4].Value = model.Value2;
            parameters[5].Value = model.Value3;
            parameters[6].Value = model.CatgID;
            parameters[7].Value = model.Value;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.BaseDictionaryDetail DataRowToModel(DataRow row)
 {
     Maticsoft.Model.BaseDictionaryDetail model = new Maticsoft.Model.BaseDictionaryDetail();
     if (row != null)
     {
         if (row["Idx"] != null && row["Idx"].ToString() != "")
         {
             model.Idx = int.Parse(row["Idx"].ToString());
         }
         if (row["CatgID"] != null && row["CatgID"].ToString() != "")
         {
             model.CatgID = int.Parse(row["CatgID"].ToString());
         }
         if (row["ParentCatgID"] != null && row["ParentCatgID"].ToString() != "")
         {
             model.ParentCatgID = int.Parse(row["ParentCatgID"].ToString());
         }
         if (row["Caption"] != null)
         {
             model.Caption = row["Caption"].ToString();
         }
         if (row["Value"] != null)
         {
             model.Value = row["Value"].ToString();
         }
         if (row["Value1"] != null)
         {
             model.Value1 = row["Value1"].ToString();
         }
         if (row["Value2"] != null)
         {
             model.Value2 = row["Value2"].ToString();
         }
         if (row["Value3"] != null)
         {
             model.Value3 = row["Value3"].ToString();
         }
     }
     return(model);
 }
コード例 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.BaseDictionaryDetail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BaseDictionaryDetail(");
            strSql.Append("Idx,CatgID,ParentCatgID,Caption,Value,Value1,Value2,Value3)");
            strSql.Append(" values (");
            strSql.Append("@Idx,@CatgID,@ParentCatgID,@Caption,@Value,@Value1,@Value2,@Value3)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Idx",          SqlDbType.Int,       4),
                new SqlParameter("@CatgID",       SqlDbType.Int,       4),
                new SqlParameter("@ParentCatgID", SqlDbType.Int,       4),
                new SqlParameter("@Caption",      SqlDbType.NVarChar, 50),
                new SqlParameter("@Value",        SqlDbType.NVarChar, 50),
                new SqlParameter("@Value1",       SqlDbType.NVarChar, 50),
                new SqlParameter("@Value2",       SqlDbType.NVarChar, 50),
                new SqlParameter("@Value3",       SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Idx;
            parameters[1].Value = model.CatgID;
            parameters[2].Value = model.ParentCatgID;
            parameters[3].Value = model.Caption;
            parameters[4].Value = model.Value;
            parameters[5].Value = model.Value1;
            parameters[6].Value = model.Value2;
            parameters[7].Value = model.Value3;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }