Ejemplo n.º 1
0
 private void BindData()
 {
     if (xdid != -1)
     {
         Pingjiaxiangdian pd = FTInterviewBLL.PingjiaxiangdianManage.GetPXXDbyId(xdid);
         myEditor.Value   = pd.Content;
         ScoreValue.Value = pd.Score + "";
     }
 }
        public static int Add(Pingjiaxiangdian pjxd)
        {
            String sql = "insert into pingjiaxiangdian(content,score) values(@content,@score)";
            List <MySqlParameter> para_list = new List <MySqlParameter>();

            para_list.Add(new MySqlParameter("@content", pjxd.Content));
            para_list.Add(new MySqlParameter("@score", pjxd.Score));

            return(MySqlDBHelper.ExecuteCommand(sql, para_list.ToArray()));
        }
        public static int Update(Pingjiaxiangdian pjxd)
        {
            String sql = "update pingjiaxiangdian set content=@content,score=@score where id=@id";
            List <MySqlParameter> para_list = new List <MySqlParameter>();

            para_list.Add(new MySqlParameter("@id", pjxd.Id));
            para_list.Add(new MySqlParameter("@content", pjxd.Content));
            para_list.Add(new MySqlParameter("@score", pjxd.Score));

            return(MySqlDBHelper.ExecuteCommand(sql, para_list.ToArray()));
        }
        public static Pingjiaxiangdian GetPXXDbyId(int xdid)
        {
            String           sql = "select * from pingjiaxiangdian where id=" + xdid;
            DataTable        dt  = MySqlDBHelper.GetDataSet(sql);
            Pingjiaxiangdian st  = new Pingjiaxiangdian();

            foreach (DataRow dr in dt.Rows)
            {
                st.Id      = Convert.ToInt32(dr["id"].ToString());
                st.Content = dr["content"].ToString();
                st.Score   = Convert.ToInt32(dr["score"].ToString());
                return(st);
            }
            return(null);
        }
        public static List <Pingjiaxiangdian> GetAll()
        {
            String    sql = "select * from pingjiaxiangdian order by id asc ";
            DataTable dt  = MySqlDBHelper.GetDataSet(sql);
            List <Pingjiaxiangdian> list = new List <Pingjiaxiangdian>();

            foreach (DataRow dr in dt.Rows)
            {
                Pingjiaxiangdian st = new Pingjiaxiangdian();
                st.Id      = Convert.ToInt32(dr["id"].ToString());
                st.Content = dr["content"].ToString();
                st.Score   = Convert.ToInt32(dr["score"].ToString());
                list.Add(st);
            }
            return(list);
        }
Ejemplo n.º 6
0
        protected void Save_Click(object sender, EventArgs e)
        {
            Pingjiaxiangdian pxd = new Pingjiaxiangdian();

            pxd.Content = myEditor.Value;
            pxd.Score   = 0;
            if (xdid != -1)
            {
                if (ScoreValue.Value != null && ScoreValue.Value != "")
                {
                    try
                    {
                        int s = Convert.ToInt32(ScoreValue.Value);
                        pxd.Score = s;
                        pxd.Id    = xdid;
                        FTInterviewBLL.PingjiaxiangdianManage.Update(pxd);
                        Response.Write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
                        Response.Write("<script language=javascript>alert('更新成功!')</script>");
                    }
                    catch (System.Exception ex)
                    {
                        Response.Write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
                        Response.Write("<script language=javascript>alert('输入不合法!')</script>");
                    }
                }
            }
            else
            {
                if (ScoreValue.Value != null && ScoreValue.Value != "")
                {
                    try
                    {
                        int s = Convert.ToInt32(ScoreValue.Value);
                        pxd.Score = s;
                        FTInterviewBLL.PingjiaxiangdianManage.Add(pxd);
                        Response.Write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
                        Response.Write("<script language=javascript>alert('添加成功!')</script>");
                    }
                    catch (System.Exception ex)
                    {
                        Response.Write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
                        Response.Write("<script language=javascript>alert('输入不合法!')</script>");
                    }
                }
            }
        }
 public static int Update(Pingjiaxiangdian pjxd)
 {
     return(FTInterviewDAL.PingjiaxiangdianService.Update(pjxd));
 }
 public static int Add(Pingjiaxiangdian pjxd)
 {
     return(FTInterviewDAL.PingjiaxiangdianService.Add(pjxd));
 }