示例#1
0
        public static BusinessCard GetCard(string id)
        {
            /* BusinessCardGet
              @id varchar(32)
            */
            BusinessCard card = new BusinessCard();

            SqlParameter[] prams ={
                Database.MakeInParam("@id",SqlDbType.VarChar,32,id)
            };

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "BusinessCardGet", prams);
                /*[Id],Guid, UserId, [Name], HasBack, Enable, [Datetime], Texts*/
                if (reader.Read())
                {
                    card.Id = reader.GetInt32(0);
                    card.Guid = reader.GetString(1);
                    card.UserId = reader.GetInt32(2);
                    card.Name = reader.GetString(3);
                    card.HasBack = reader.GetString(4)=="1";
                    card.Enable = reader.GetString(5) == "1";
                    card.Datetime = reader.GetDateTime(6);
                    card.Texts = reader.GetString(7);
                }
                reader.Close();
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return card;
        }
示例#2
0
        private static ArrayList GetCards(int uid, int enable, int hasBack, Pager pager)
        {
            ArrayList list = new ArrayList();
            /*
             BusinessCardList
            @uid int=0,
            @enabled int=-1,
            @hasback int=-1,
            @pageindex int=1,
            @pagesize int=20,
            @sort int=0
             */
            SqlParameter[] prams ={
                Database.MakeReturnValueParam("@returnValue"),
                Database.MakeInParam("@uid",SqlDbType.Int,uid),
                Database.MakeInParam("@enable",SqlDbType.Int,enable),
                Database.MakeInParam("@hasback",SqlDbType.Int,hasBack),
                Database.MakeInParam("@pageindex",SqlDbType.Int,pager.PageIndex),
                Database.MakeInParam("@pagesize",SqlDbType.Int,pager.PageSize),
                Database.MakeInParam("@sort",SqlDbType.Int,pager.SortNum)
            };

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "BusinessCardList", prams);

                if (reader.Read())
                {
                    pager.RecordCount = reader.GetInt32(0);

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            /*[Id],Guid, UserId, [Name], HasBack, Enable, [Datetime]*/
                            BusinessCard card = new BusinessCard();
                            card.Id = reader.GetInt32(0);
                            card.Guid = reader.GetString(1);
                            card.UserId = reader.GetInt32(2);
                            card.Name = reader.GetString(3);
                            card.HasBack = (reader.GetString(4) == "1");
                            card.Enable = (reader.GetString(5) == "1");
                            card.Datetime = reader.GetDateTime(6);
                            list.Add(card);
                        }
                    }
                }
                reader.Close();
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return list;
        }
示例#3
0
        public static int SaveCard(BusinessCard card)
        {
            /* BusinessCardSave
                @guid char(32),
                @uid int=0,
                @name varchar(50)='',
                @hasBack char(1)='0',
                @enable char(1)='1',
                @texts varchar(1000)=''
                        */
            SqlParameter[] prams ={
                Database.MakeReturnValueParam("@returnValue"),
                Database.MakeInParam("@guid",SqlDbType.Char,32,card.Guid),
                Database.MakeInParam("@uid",SqlDbType.Int,card.UserId),
                Database.MakeInParam("@name",SqlDbType.VarChar,30,card.Name),
                Database.MakeInParam("@hasBack",SqlDbType.Char,1,card.HasBack?"1":"0"),
                Database.MakeInParam("@enable",SqlDbType.Char,1,card.Enable?"1":"0"),
                Database.MakeInParam("@texts",SqlDbType.VarChar,1000,card.Texts)
            };

            int newId = 0;
            try
            {
                newId = Database.ExecuteNonQuery(CommandType.StoredProcedure, "BusinessCardSave", prams);
            }
            catch
            {
                newId = -1;
            }

            return newId;
        }
示例#4
0
 public static int SaveCard(string guid,int uid,string name,bool hasBack,bool enable,string texts)
 {
     BusinessCard card = new BusinessCard();
     card.Guid = guid;
     card.UserId = uid;
     card.Name = name;
     card.HasBack = hasBack;
     card.Enable = enable;
     card.Texts = texts;
     return SaveCard(card);
 }