コード例 #1
0
        //Create an enquiry and send to the seller.
        public bool createEnquiry(Account account, Enquiry enq)
        {
            String enquiryId = this.createRandomId();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = this.conn;
                cmd.CommandText = "INSERT INTO enquiries (id, sellerId, buyerId, subject, questions, response) VALUES(@Id, @SellerId, @BuyerId, @Subject, @Questions, @Response)";
                cmd.Prepare();

                cmd.Parameters.AddWithValue("@Id", enquiryId);
                cmd.Parameters.AddWithValue("@SellerId", enq.getSellerId());
                cmd.Parameters.AddWithValue("@BuyerId", enq.getBuyerId());
                cmd.Parameters.AddWithValue("@Subject", enq.getSubject());
                cmd.Parameters.AddWithValue("@Questions", enq.getQuestions());
                cmd.Parameters.AddWithValue("@Response", enq.getResponse());

                cmd.ExecuteNonQuery();

                this.conn.Close();

                return(true);
            }
            catch (SqlException ex)
            {
                Debug.WriteLine(ex.ToString());
                this.conn.Close();
                return(false); //error
            }
        }
コード例 #2
0
        //Seller can reply to enquiry
        public bool replyToEnquiry(Account account, Enquiry enq)
        {
            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = this.conn;
                cmd.CommandText = "UPDATE enquiries SET response = @Response WHERE id = @EnquiryId AND sellerId = @SellerId";
                cmd.Prepare();

                cmd.Parameters.AddWithValue("@EnquiryId", enq.getId());
                cmd.Parameters.AddWithValue("@Response", enq.getResponse());
                cmd.Parameters.AddWithValue("@SellerId", account.getId());


                cmd.ExecuteNonQuery();

                this.conn.Close();

                return(true);
            }
            catch (SqlException ex)
            {
                Debug.WriteLine(ex.ToString());
                this.conn.Close();
                return(false); //error
            }
        }
コード例 #3
0
ファイル: Buyer.cs プロジェクト: JarredJones788/Final_Project
        public bool contactSeller(Enquiry enq)
        {
            Database db = new Database();

            if (db.createEnquiry(this, enq))
            {
                return(true);
            }
            return(false);
        }
コード例 #4
0
        public bool replyToEnquiry(Enquiry enq)
        {
            Database db = new Database();

            if (db.replyToEnquiry(this, enq))
            {
                return(true);
            }

            return(false);
        }