Ejemplo n.º 1
0
        public void Update(SysParam item)
        {
            if(item.ChangedPropertyCount>0)
                {
                    StringBuilder sqlbuilder = new StringBuilder();
                    sqlbuilder.Append("UPDATE [SysParams] SET ");
                    Dictionary<string,string> cols =new Dictionary<string,string>();
                    cols.Add("ParamName","[ParamName]");
                    cols.Add("ParamValue","[ParamValue]");
                    cols.Add("Remark","[Remark]");
                    int i = 0;
                    //UPDATE COLUMNS
                    foreach (string p in item.ChangedPropertyList)
                    {
                        if(!cols.ContainsKey(p))
                        {
                            continue;
                        }
                        if (i > 0)
                        {
                            sqlbuilder.Append(",");
                        }
                        sqlbuilder.AppendFormat("{0}=@{1}", cols[p], p);
                        i++;
                    }
                    //WHERE;
                    sqlbuilder.Append(" WHERE [ParamCode]=@ParamCode");

                    List<SqlParameter> SPParams = new List<SqlParameter>();
                     SPParams.Add(new SqlParameter("@ParamCode",item.ParamCode));

                    if(item.IsChanged("ParamName"))
                    {
                        SPParams.Add(new SqlParameter("@ParamName",item.ParamName));
                    }
                    if(item.IsChanged("ParamValue"))
                    {
                        SPParams.Add(new SqlParameter("@ParamValue",item.ParamValue));
                    }
                    if(item.IsChanged("Remark"))
                    {
                        SPParams.Add(new SqlParameter("@Remark",item.Remark));
                    }
                    base.ExecuteNonQuery(sqlbuilder.ToString(), SPParams.ToArray());
                }
        }
Ejemplo n.º 2
0
 public void Save(SysParam item)
 {
     if(item.IsNew)
         {
             Insert(item);
         }
         else
         {
             Update(item);
         }
 }
Ejemplo n.º 3
0
 public void Insert(SysParam item)
 {
     string sql="INSERT INTO [SysParams] ([ParamCode],[ParamName],[ParamValue],[Remark]) VALUES (@ParamCode,@ParamName,@ParamValue,@Remark)";
         List<SqlParameter> SPParams = new List<SqlParameter>();
         SPParams.Add(new SqlParameter("@ParamCode",item.ParamCode));
         SPParams.Add(new SqlParameter("@ParamName",item.ParamName));
         SPParams.Add(new SqlParameter("@ParamValue",item.ParamValue));
         SPParams.Add(new SqlParameter("@Remark",item.Remark));
         base.ExecuteNonQuery(sql, SPParams.ToArray());
 }
Ejemplo n.º 4
0
 public List<SysParam> QueryAll()
 {
     string sql ="SELECT [ParamCode],[ParamName],[ParamValue],[Remark] FROM [SysParams]";
         List<SysParam>  list =new List<SysParam>();
         using(IDataReader reader = base.ExcuteDataReader(sql))
         {
             while(reader.Read())
             {
                 SysParam item =new SysParam();
                 item.ParamCode = reader.GetString(0);
                     if(!reader.IsDBNull(1))
                  {
                     item.ParamName = reader.GetString(1);
                  }
                  if(!reader.IsDBNull(2))
                  {
                     item.ParamValue = reader.GetString(2);
                  }
                  if(!reader.IsDBNull(3))
                  {
                     item.Remark = reader.GetString(3);
                  }
                  						list.Add(item);
             }
         }
         return list;
 }
Ejemplo n.º 5
0
        public SysParam Get(string key)
        {
            string sql = "SELECT [ParamCode],[ParamName],[ParamValue],[Remark] FROM [SysParams] WHERE [ParamCode]=@ParamCode";
                SqlParameter p =new SqlParameter("@ParamCode",key);
                SysParam item =null;
                using(IDataReader reader = base.ExcuteDataReader(sql,p))
                {
                    if(reader.Read())
                    {
                        item =new SysParam();
                        item.ParamCode = reader.GetString(0);
                            if(!reader.IsDBNull(1))
                         {
                            item.ParamName = reader.GetString(1);
                         }
                         if(!reader.IsDBNull(2))
                         {
                            item.ParamValue = reader.GetString(2);
                         }
                         if(!reader.IsDBNull(3))
                         {
                            item.Remark = reader.GetString(3);
                         }

                    }
                }
                return item;
        }