Ejemplo n.º 1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        short grade = Convert.ToInt16(ddlGrade.SelectedItem.Value); // 获取用户评分
        string content = TextBox1.Text; // 评论内容

        if (string.IsNullOrEmpty(content)) {
            ClientScript.RegisterStartupScript(Page.GetType(), "Message", "<script>alert('请输入评论内容')</script>");
            return;
        }

        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DataSource"].ConnectionString);
        string insert = string.Format("insert into CommentTable(OrderID, UserName, LineID, Grade, Content) Values('{0}', '{1}', {2}, {3}, '{4}')", orderID, Session["UserName"].ToString(), lineID, grade, content);
        SqlCommand cmd = new SqlCommand(insert, conn);

        // 添加评论
        try {
            conn.Open();
            cmd.ExecuteNonQuery();

            var table = new CommentTableAdapters.OrderInfoTableAdapter();
            table.UpdateQueryIsComment(true, orderID);  // 更新数据库
            ClientScript.RegisterStartupScript(Page.GetType(), "ss", "<script>alert('评论成功');{location.href='UserPage.aspx'}</script>");
        } catch {
        } finally {
            conn.Close();
        }
        //ClientScript.RegisterStartupScript(Page.GetType(), "ss", "<script>alert('评论成功')</script>");
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Title = "线路评价";
        orderID = Request["orderID"];    // 获取订单编号
        var table = new CommentTableAdapters.OrderInfoTableAdapter();
        var result = table.GetDataByOrderID(orderID).Single();
        lineID = result.LineID;
        string travelDate = result.TravelDate.ToString("yyyy-MM-dd");

        var lineTable = new ViewLineTableAdapters.TourLineTableAdapter();
        var lineName = lineTable.GetDataByID(lineID).Single().LineName;

        lblLineName.Text = "线路名称" + lineName;
        lblTravelDate.Text = "旅行日期: " + travelDate;
    }