예제 #1
0
        public static int UpdatePaymentDetails(Paymentdetails p)
        {
            int rowsupdated = 0;

            SqlConnection conn = null;

            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SWENConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "UPDATE PaymentDetails SET  guestnric=@guestnric, paymentmeth=@paymentmeth, creditcardnum=@creditcardnum, creditholdername=@creditholdername, expirydate=@expirydate, firstname=@firstname, lastname=@lastname WHERE reservationnum=@reservationnum";
                comm.Parameters.AddWithValue("@guestnric", p.Nric);
                comm.Parameters.AddWithValue("@paymentmeth", p.Paymentmeth);
                comm.Parameters.AddWithValue("@creditcardnum", p.Creditcardnum);
                comm.Parameters.AddWithValue("@creditholdername", p.Creditholdername);
                comm.Parameters.AddWithValue("@expirydate", p.Expirydate);
                comm.Parameters.AddWithValue("@firstname", p.Firstname);
                comm.Parameters.AddWithValue("@lastname", p.Lastname);
                comm.Parameters.AddWithValue("@reservationnum", p.Reservationnum);

                rowsupdated = comm.ExecuteNonQuery();
                conn.Close();
            }
            catch (SqlException e)
            {
                throw e;
            }
            return(rowsupdated);
        }
예제 #2
0
        public static int InsertPayment(Paymentdetails p)
        {
            int rowsinserted = 0;

            SqlConnection conn = null;

            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SWENConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "INSERT INTO PaymentDetails(guestnric,paymentmeth,creditcardnum,creditholdername,expirydate,firstname,lastname,reservationnum)" +
                                   " VALUES (@guestnric,@paymentmeth,@creditcardnum,@creditholdername,@expirydate,@firstname,@lastname,@reservationnum)";

                comm.Parameters.AddWithValue("@guestnric", p.Nric);
                comm.Parameters.AddWithValue("@paymentmeth", p.Paymentmeth);
                comm.Parameters.AddWithValue("@creditcardnum", p.Creditcardnum);
                comm.Parameters.AddWithValue("@creditholdername", p.Creditholdername);
                comm.Parameters.AddWithValue("@expirydate", p.Expirydate);
                comm.Parameters.AddWithValue("@firstname", p.Firstname);
                comm.Parameters.AddWithValue("@lastname", p.Lastname);
                comm.Parameters.AddWithValue("@reservationnum", p.Reservationnum);

                rowsinserted = comm.ExecuteNonQuery();

                conn.Close();
            }
            catch (SqlException e)
            {
                throw e;
            }
            return(rowsinserted);
        }
예제 #3
0
        public static Paymentdetails GetPaymentdetailsByNum(string reservationnum)
        {
            Paymentdetails p    = new Paymentdetails();
            SqlConnection  conn = null;

            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SWENConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection  = conn;
                comm.CommandText = "SELECT * FROM PaymentDetails WHERE reservationnum=@reservationnum";
                comm.Parameters.AddWithValue("@reservationnum", reservationnum);
                SqlDataReader dr = comm.ExecuteReader();
                if (dr.Read())
                {
                    p.Reservationnum = (string)dr["reservationnum"];

                    p.Paymentmeth      = (string)dr["paymentmeth"];
                    p.Creditcardnum    = (string)dr["creditcardnum"];
                    p.Creditholdername = (string)dr["creditholdername"];
                    p.Expirydate       = (string)dr["expirydate"];
                }
                dr.Close();
            }

            catch (SqlException e)
            {
                throw e;
            }

            return(p);
        }
예제 #4
0
        protected void rsvcreatebtn_Click(object sender, EventArgs e)
        {
            Reservation r = new Reservation();

            r.Reservationnum = rsv2tbx.Text;
            r.Roomnum = rm2tbx.Text;
            r.Firstname = gf2tbx.Text;
            r.Lastname = gl2tbx.Text;
            r.Nric = nric2tbx.Text;
            r.Numofadult = adg1tbx.Text;
            r.Numofchild = ch1tbx.Text;
            r.Contactnum = cnt1tbx.Text;
            r.Emailadd = email2tbx.Text;
            r.Homeadd = home2tbx.Text;
            r.Postalcode = Convert.ToInt32(post2tbx.Text);
            r.Country = co2tbx.Text;
            r.Paymentmeth = meth2ddl.Text;
            r.Checkindate = ci2tbx.Text;
            r.Checkoutdate = cho2tbx.Text;
            r.Addremarks = add2tbx.Text;
            r.Indicationlate = ind2tbx.Text;
            r.Roomclass = class2tbx.Text;

            Paymentdetails p = new Paymentdetails();
            p.Paymentmeth = meth2ddl.Text;
            p.Creditcardnum = cred2tbx.Text;
            p.Creditholdername = holder2tbx.Text;
            p.Expirydate = exp2tbx.Text;
            p.Nric = nric2tbx.Text;
            p.Firstname = gf2tbx.Text;
            p.Lastname = gl2tbx.Text;
            p.Reservationnum = rsv2tbx.Text;

            if (SWENDbmanager.InsertReservation(r) == 1)
            {
                lblsuccesscreate.Text = "Reservation Creation Completed..";
            }
            else
            {
                lblsuccesscreate.Text = "Reservation Creation Failed..";
            }

            if (SWENDbmanager.InsertPayment(p) == 1)
            {
                lblpaycreated.Text = "Payment Details Creation Completed..";
            }
            else
            {
                lblpaycreated.Text = "Payment Details Creation Failed..";
            }
        }
예제 #5
0
        protected void updbtn_Click(object sender, EventArgs e)
        {
            Reservation r = new Reservation();
            r.Firstname = gfnametbx.Text;
            r.Lastname = glnametbx.Text;
            r.Nric = nrictbx.Text;
            r.Roomnum = roomtbx.Text;
            r.Roomclass = classtbx.Text;
            r.Contactnum = cntbx.Text;
            r.Emailadd = emailtbx.Text;
            r.Country = ctbx.Text;
            r.Homeadd = hometbx.Text;
            r.Postalcode = Convert.ToInt32(postaltbx.Text);
            r.Checkindate = citbx.Text;
            r.Checkoutdate = cotbx.Text;
            r.Paymentmeth = paymentddl.Text;
            r.Indicationlate = indtbx.Text;
            r.Addremarks = addrtbx.Text;
            r.Reservationnum = rsvnotbx.Text;
            r.Numofchild = childtbx.Text;
            r.Numofadult = adulttbx.Text;

            Paymentdetails p = new Paymentdetails();
            p.Nric = nrictbx.Text;
            p.Paymentmeth = paymentddl.Text;
            p.Creditcardnum = cardnotbx.Text;
            p.Creditholdername = holdertbx.Text;
            p.Expirydate = exptbx.Text;
            p.Firstname = gfnametbx.Text;
            p.Lastname = glnametbx.Text;
            p.Reservationnum = rsvnotbx.Text;

            if (SWENDbmanager.UpdateReservation(r) == 1)
            {
                lblSuccessful.Text = "Reservation Update Completed..";
            }
            else
            {
                lblUnsuccessful.Text = "Reservation Update Failed..";
            }

            if (SWENDbmanager.UpdatePaymentDetails(p) == 1)
            {
                lblpaycompleted.Text = "Payment Details Update Completed..";
            }
            else
            {
                lblpayfailed.Text = "Payment Details Update Failed..";
            }
        }
예제 #6
0
        public static int UpdatePaymentDetails(Paymentdetails p)
        {
            int rowsupdated = 0;

            SqlConnection conn = null;
            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SWENConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandText = "UPDATE PaymentDetails SET  guestnric=@guestnric, paymentmeth=@paymentmeth, creditcardnum=@creditcardnum, creditholdername=@creditholdername, expirydate=@expirydate, firstname=@firstname, lastname=@lastname WHERE reservationnum=@reservationnum";
                comm.Parameters.AddWithValue("@guestnric", p.Nric);
                comm.Parameters.AddWithValue("@paymentmeth", p.Paymentmeth);
                comm.Parameters.AddWithValue("@creditcardnum", p.Creditcardnum);
                comm.Parameters.AddWithValue("@creditholdername", p.Creditholdername);
                comm.Parameters.AddWithValue("@expirydate", p.Expirydate);
                comm.Parameters.AddWithValue("@firstname",p.Firstname);
                comm.Parameters.AddWithValue("@lastname",p.Lastname);
                comm.Parameters.AddWithValue("@reservationnum",p.Reservationnum);

                rowsupdated = comm.ExecuteNonQuery();
                conn.Close();
            }
            catch (SqlException e)
            {
                throw e;
            }
            return rowsupdated;
        }
예제 #7
0
        public static int InsertPayment(Paymentdetails p)
        {
            int rowsinserted = 0;

            SqlConnection conn = null;
            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SWENConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandText = "INSERT INTO PaymentDetails(guestnric,paymentmeth,creditcardnum,creditholdername,expirydate,firstname,lastname,reservationnum)" +
                    " VALUES (@guestnric,@paymentmeth,@creditcardnum,@creditholdername,@expirydate,@firstname,@lastname,@reservationnum)";

                comm.Parameters.AddWithValue("@guestnric", p.Nric);
                comm.Parameters.AddWithValue("@paymentmeth", p.Paymentmeth);
                comm.Parameters.AddWithValue("@creditcardnum", p.Creditcardnum);
                comm.Parameters.AddWithValue("@creditholdername", p.Creditholdername);
                comm.Parameters.AddWithValue("@expirydate", p.Expirydate);
                comm.Parameters.AddWithValue("@firstname", p.Firstname);
                comm.Parameters.AddWithValue("@lastname",p.Lastname);
                comm.Parameters.AddWithValue("@reservationnum",p.Reservationnum);

                rowsinserted = comm.ExecuteNonQuery();

                conn.Close();
            }
            catch (SqlException e)
            {
                throw e;
            }
            return rowsinserted;
        }
예제 #8
0
        public static Paymentdetails GetPaymentdetailsByNum(string reservationnum)
        {
            Paymentdetails p = new Paymentdetails();
            SqlConnection conn = null;
            try
            {
                conn = new SqlConnection();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["SWENConnectionString"].ConnectionString;
                conn.Open();
                SqlCommand comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandText = "SELECT * FROM PaymentDetails WHERE reservationnum=@reservationnum";
                comm.Parameters.AddWithValue("@reservationnum", reservationnum);
                SqlDataReader dr = comm.ExecuteReader();
                if (dr.Read())
                {

                    p.Reservationnum = (string)dr["reservationnum"];

                    p.Paymentmeth = (string)dr["paymentmeth"];
                    p.Creditcardnum = (string)dr["creditcardnum"];
                    p.Creditholdername = (string)dr["creditholdername"];
                    p.Expirydate = (string)dr["expirydate"];

                }
                dr.Close();
            }

            catch (SqlException e)
            {
                throw e;
            }

            return p;
        }