コード例 #1
0
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        if (txtsubject.Text.Trim() == "") {
            Alert.Show("กรุณากรอกชื่อเรื่องด้วย !!!");
            txtsubject.Focus();
            return;
        }

        if (txtcomment.Text.Trim() == "") {
            Alert.Show("กรุณากรอกข้อเสนอแนะด้วย !!!");
            txtcomment.Focus();
            return;
        }

        try
        {
            MemberService service = new MemberService();
            Comment _comment = new Comment();
            _comment.ID = 1;
            _comment.IP = "192.18.1.1";
            _comment.Subject = txtsubject.Text.Trim();
            _comment.CommentDecription = txtcomment.Text.Trim();

            if (service.CreateComment(_comment) == true)
            {
                clear();
                Alert.Show("บันทึกเรียบร้อยแล้ว");

            }

        }
        catch (Exception ex) {
            Alert.Show("ไม่สามารถบันทึกได้เนื่องจาก " + ex.Message);
        }
    }
コード例 #2
0
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        if (txtsubject.Text.Trim() == "")
        {
            Alert.Show("กรุณากรอกชื่อเรื่องด้วย !!!");
            txtsubject.Focus();
            return;
        }

        if (txtcomment.Text.Trim() == "")
        {
            Alert.Show("กรุณากรอกข้อเสนอแนะด้วย !!!");
            txtcomment.Focus();
            return;
        }
        if (Session["update"].ToString() == ViewState["update"].ToString())
        {
            try
            {
                string nowip;
                nowip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
                if (nowip == null)
                {
                    nowip = Request.ServerVariables["REMOTE_ADDR"];
                }

                MemberService service = new MemberService();
                Comment _comment = new Comment();
                _comment.UserType = 1;
                _comment.IP = nowip;
                _comment.Subject = txtsubject.Text.Trim();
                _comment.CommentDecription = txtcomment.Text.Trim();

                if (service.CreateComment(_comment) == true)
                {
                    clear();
                    Alert.Show("บันทึกเรียบร้อยแล้ว , ขอบคุณสำหรับคำแนะนำนะครับ !!!");

                }

                Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());

            }
            catch (Exception ex)
            {
                Alert.Show("ไม่สามารถบันทึกได้เนื่องจาก " + ex.Message);
            }

        }
    }