Exemple #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (IsPost)
            {
                switch (AjaxAction)
                {
                    case "ExpertPage.save":
                        SaveExpert();
                        break;
                }
            }
            else
            {
                if (Request["id"] != null)
                {
                    CurrentExpert = Expert.Get(Request["id"].Trim());
                }
                else if (Request.QueryString.ToString().Length == 32)
                {
                    CurrentExpert = Expert.Get(Request.QueryString.ToString());
                }

                if (CurrentExpert == null)
                {
                    CurrentExpert = new Expert("","");
                }
            }
        }
Exemple #2
0
        public static ArrayList List(string keywords, Pager pager)
        {
            /*
             ExpertList
             * @keywords varchar(50)='',
                @pageIndex int=1,
                @pageSize int=20,
                @sort int=0
             */
            //Id, Guid, Email,[Name]

            SqlParameter[] prams ={
                Database.MakeInParam("@keywords",SqlDbType.VarChar,50,keywords),
                Database.MakeInParam("@pageIndex",SqlDbType.Int,pager.PageIndex),
                Database.MakeInParam("@pageSize",SqlDbType.Int,pager.PageSize),
                Database.MakeInParam("@sort",SqlDbType.Int,pager.SortNum)
            };

            ArrayList list = new ArrayList();

            SqlDataReader reader = null;
            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "ExpertList", prams);

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

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            Expert exp = new Expert();
                            exp.id = reader.GetInt32(0);
                            exp.guid = reader.GetString(1);
                            exp.email = reader.GetString(2);
                            exp.name = reader.GetString(3);
                            list.Add(exp);
                        }
                    }
                }
                reader.Close();
            }
            catch
            {
                throw;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return list;
        }
Exemple #3
0
        public static Expert Get(string guidOrEmail)
        {
            /*
             ExpertGet
            @id varchar(50)
             */
            Expert expt = null;

            SqlDataReader reader = null;

            try
            {
                reader = Database.ExecuteReader(CommandType.StoredProcedure, "ExpertGet",
                    new SqlParameter[] { Database.MakeInParam("@id", SqlDbType.VarChar, 50, guidOrEmail) });
                if (reader.Read())
                {
                    expt = new Expert();
                    expt.id = reader.GetInt32(0);
                    expt.guid = reader.GetString(1);
                    expt.email = reader.GetString(2);
                    expt.name = reader.GetString(3);
                }
            }
            catch
            {
                //
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return expt;
        }
Exemple #4
0
 private void SaveExpert()
 {
     Response.Clear();
     if (Request.Form["expId"] != null &&
         Request.Form["expName"] != null &&
         Request.Form["expEmail"] != null)
     {
         Expert exp = new Expert(Request.Form["expEmail"].Trim(), Request.Form["expName"].Trim());
         exp.Save(Convert.ToInt32(Request.Form["expId"]));
         Response.Write(exp.Id);
     }
     Response.End();
 }
Exemple #5
0
 protected ExpertPage()
     : base()
 {
     CurrentExpert = new Expert("", "");
 }