Example #1
0
 public void Save(ShortCut item)
 {
     if (item.IsNew)
     {
         Insert(item);
     }
     else
     {
         Update(item);
     }
 }
Example #2
0
        public void Insert(ShortCut item)
        {
            string sql = "INSERT INTO [ShortCut] ([ShortCutName],[Remark],[PrivilegeCode],[UserUID],[LastModifyTime],[Sequence]) VALUES (@ShortCutName,@Remark,@PrivilegeCode,@UserUID,@LastModifyTime,@Sequence)";

            List <SqlParameter> SPParams = new List <SqlParameter>();

            SPParams.Add(new SqlParameter("@ShortCutName", item.ShortCutName));
            SPParams.Add(new SqlParameter("@Remark", item.Remark));
            SPParams.Add(new SqlParameter("@PrivilegeCode", item.PrivilegeCode));
            SPParams.Add(new SqlParameter("@UserUID", item.UserUID));
            SPParams.Add(new SqlParameter("@LastModifyTime", item.LastModifyTime));
            SPParams.Add(new SqlParameter("@Sequence", item.Sequence));
            base.ExecuteNonQuery(sql, SPParams.ToArray());
        }
Example #3
0
        public void Update(ShortCut item)
        {
            if (item.ChangedPropertyCount > 0)
            {
                StringBuilder sqlbuilder = new StringBuilder();
                sqlbuilder.Append("UPDATE [ShortCut] SET ");
                Dictionary <string, string> cols = new Dictionary <string, string>();
                cols.Add("ShortCutName", "[ShortCutName]");
                cols.Add("Remark", "[Remark]");
                cols.Add("PrivilegeCode", "[PrivilegeCode]");
                cols.Add("UserUID", "[UserUID]");
                cols.Add("LastModifyTime", "[LastModifyTime]");
                cols.Add("Sequence", "[Sequence]");
                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 [ShortCutID]=@ShortCutID");

                List <SqlParameter> SPParams = new List <SqlParameter>();
                SPParams.Add(new SqlParameter("@ShortCutID", item.ShortCutID));
                if (item.IsChanged("ShortCutName"))
                {
                    SPParams.Add(new SqlParameter("@ShortCutName", item.ShortCutName));
                }
                SPParams.Add(new SqlParameter("@Remark", item.Remark));
                SPParams.Add(new SqlParameter("@PrivilegeCode", item.PrivilegeCode));
                SPParams.Add(new SqlParameter("@UserUID", item.UserUID));
                SPParams.Add(new SqlParameter("@LastModifyTime", item.LastModifyTime));
                SPParams.Add(new SqlParameter("@Sequence", item.Sequence));
                base.ExecuteNonQuery(sqlbuilder.ToString(), SPParams.ToArray());
            }
        }
Example #4
0
        public void Update(ShortCut item)
        {
            if(item.ChangedPropertyCount>0)
            {
                StringBuilder sqlbuilder = new StringBuilder();
                sqlbuilder.Append("UPDATE [ShortCut] SET ");
                Dictionary<string,string> cols =new Dictionary<string,string>();
                cols.Add("ShortCutName","[ShortCutName]");
                cols.Add("Remark","[Remark]");
                cols.Add("PrivilegeCode","[PrivilegeCode]");
                cols.Add("UserUID","[UserUID]");
                cols.Add("LastModifyTime","[LastModifyTime]");
                cols.Add("Sequence","[Sequence]");
                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 [ShortCutID]=@ShortCutID");

                List<SqlParameter> SPParams = new List<SqlParameter>();
                SPParams.Add(new SqlParameter("@ShortCutID", item.ShortCutID));
                if(item.IsChanged("ShortCutName"))
                {
                  SPParams.Add(new SqlParameter("@ShortCutName", item.ShortCutName));
                }
                SPParams.Add(new SqlParameter("@Remark", item.Remark));
                SPParams.Add(new SqlParameter("@PrivilegeCode", item.PrivilegeCode));
                SPParams.Add(new SqlParameter("@UserUID", item.UserUID));
                SPParams.Add(new SqlParameter("@LastModifyTime", item.LastModifyTime));
                SPParams.Add(new SqlParameter("@Sequence", item.Sequence));
                base.ExecuteNonQuery(sqlbuilder.ToString(), SPParams.ToArray());

            }
        }
Example #5
0
 public void Save(ShortCut item)
 {
     if (item.IsNew)
     {
         Insert(item);
     }
     else
     {
         Update(item);
     }
 }
Example #6
0
        public void Insert(ShortCut item)
        {
            string sql = "INSERT INTO [ShortCut] ([ShortCutName],[Remark],[PrivilegeCode],[UserUID],[LastModifyTime],[Sequence]) VALUES (@ShortCutName,@Remark,@PrivilegeCode,@UserUID,@LastModifyTime,@Sequence)";

            List<SqlParameter> SPParams = new List<SqlParameter>();
            SPParams.Add(new SqlParameter("@ShortCutName", item.ShortCutName));
            SPParams.Add(new SqlParameter("@Remark", item.Remark));
            SPParams.Add(new SqlParameter("@PrivilegeCode", item.PrivilegeCode));
            SPParams.Add(new SqlParameter("@UserUID", item.UserUID));
            SPParams.Add(new SqlParameter("@LastModifyTime", item.LastModifyTime));
            SPParams.Add(new SqlParameter("@Sequence", item.Sequence));
            base.ExecuteNonQuery(sql, SPParams.ToArray());
        }
Example #7
0
 public List<ShortCut> QueryAll()
 {
     string sql ="SELECT [ShortCutID],[ShortCutName],[Remark],[PrivilegeCode],[UserUID],[LastModifyTime],[Sequence] FROM [ShortCut]";
         List<ShortCut>  list =new List<ShortCut>();
         using(IDataReader reader = base.ExcuteDataReader(sql))
         {
             while(reader.Read())
             {
                 ShortCut item =new ShortCut();
                 item.ShortCutID = reader.GetInt32(0);
                     item.ShortCutName = reader.GetString(1);
                     if(!reader.IsDBNull(2))
                  {
                     item.Remark = reader.GetString(2);
                  }
                  if(!reader.IsDBNull(3))
                  {
                     item.PrivilegeCode = reader.GetString(3);
                  }
                  if(!reader.IsDBNull(4))
                  {
                     item.UserUID = reader.GetString(4);
                  }
                  if(!reader.IsDBNull(5))
                  {
                     item.LastModifyTime = reader.GetDateTime(5);
                  }
                  if(!reader.IsDBNull(6))
                  {
                     item.Sequence = reader.GetInt32(6);
                  }
                  						list.Add(item);
             }
         }
         return list;
 }
Example #8
0
 public void Insert(ShortCut item)
 {
     string sql="INSERT INTO [ShortCut] ([ShortCutName],[Remark],[PrivilegeCode],[UserUID],[LastModifyTime],[Sequence]) VALUES (@ShortCutName,@Remark,@PrivilegeCode,@UserUID,@LastModifyTime,@Sequence)";
         List<SqlParameter> SPParams = new List<SqlParameter>();
         SPParams.Add(new SqlParameter("@ShortCutName",item.ShortCutName));
         SPParams.Add(new SqlParameter("@Remark",item.Remark));
         SPParams.Add(new SqlParameter("@PrivilegeCode",item.PrivilegeCode));
         SPParams.Add(new SqlParameter("@UserUID",item.UserUID));
         SPParams.Add(new SqlParameter("@LastModifyTime",item.LastModifyTime));
         SPParams.Add(new SqlParameter("@Sequence",item.Sequence));
         sql +=";SELECT Scope_Identity()";
         object o = base.ExecuteScalar(sql, SPParams.ToArray());
         if(o!=null){
             item.ShortCutID =Convert.ToInt32(o);
         }
 }
Example #9
0
        public ShortCut Get(int key)
        {
            string sql = "SELECT [ShortCutID],[ShortCutName],[Remark],[PrivilegeCode],[UserUID],[LastModifyTime],[Sequence] FROM [ShortCut] WHERE [ShortCutID]=@ShortCutID";
                SqlParameter p =new SqlParameter("@ShortCutID",key);
                ShortCut item =null;
                using(IDataReader reader = base.ExcuteDataReader(sql,p))
                {
                    if(reader.Read())
                    {
                        item =new ShortCut();
                        item.ShortCutID = reader.GetInt32(0);
                            item.ShortCutName = reader.GetString(1);
                            if(!reader.IsDBNull(2))
                         {
                            item.Remark = reader.GetString(2);
                         }
                         if(!reader.IsDBNull(3))
                         {
                            item.PrivilegeCode = reader.GetString(3);
                         }
                         if(!reader.IsDBNull(4))
                         {
                            item.UserUID = reader.GetString(4);
                         }
                         if(!reader.IsDBNull(5))
                         {
                            item.LastModifyTime = reader.GetDateTime(5);
                         }
                         if(!reader.IsDBNull(6))
                         {
                            item.Sequence = reader.GetInt32(6);
                         }

                    }
                }
                return item;
        }