/// <summary>
        /// Method to Insert into Payment Table after validation
        /// </summary>
        /// <param name="_tObj">Object of Orders Class</param>
        /// <param name="_payInsObj">Object of Payment Class</param>
        /// <returns>Returns no. of rows affected</returns>
        public int InsertInPayment(EntityLayers.Orders _tObj, EntityLayers.Payment _payInsObj)
        {
            SqlConnection _conObj = new SqlConnection("Data Source=.;Initial Catalog=HotelDB;Integrated Security=True");
            int           _res    = 0;

            try
            {
                SqlCommand _cmd = new SqlCommand();
                _cmd.Connection  = _conObj;
                _cmd.CommandType = CommandType.StoredProcedure;
                _cmd.CommandText = "sp_payment";
                _cmd.Parameters.AddWithValue("@OrderID", _tObj._orderID);
                _cmd.Parameters.AddWithValue("@DateOfPayment", _payInsObj._dateOfPayment);
                _cmd.Parameters.AddWithValue("@PaymentMode", _payInsObj._paymentMode);
                _cmd.Parameters.AddWithValue("@BankName", _payInsObj._bankName);
                _cmd.Parameters.AddWithValue("@CardType", _payInsObj._cardType);
                _cmd.Parameters.AddWithValue("@CardNumber", _payInsObj._cardNO);
                _cmd.Parameters.AddWithValue("@NameOnCard", _payInsObj._nameOnCard);
                _cmd.Parameters.AddWithValue("@Amount", _payInsObj._totalamount);
                _conObj.Open();
                _res = _cmd.ExecuteNonQuery();
                return(_res);
            }
            catch (Exception)
            {
                throw;
            }

            finally
            {
                _conObj.Close();
            }
        }
示例#2
0
        protected void btnPay_Click(object sender, EventArgs e)
        {
            string UserId = Session["UserID"].ToString();



            EntityLayers.CardInfo _objCardInfo = new EntityLayers.CardInfo()
            {
                _bankName   = txtBankName.Text,
                _cardNO     = txtCardNumber.Text,
                _cardType   = txtCardType.Text,
                _expDate    = txtExpiryDate.Text,
                _NameOnCard = txtNameOnCard.Text
            };

            int result = _userObj.ValidateCardInfo(_objCardInfo);

            if (result == 1)
            {
                EntityLayers.Orders _tOobj = new EntityLayers.Orders()
                {
                    _orderID = int.Parse(Session["UserOrderID"].ToString())
                };


                TableCell row1 = gvTotal.Rows[0].Cells[0];
                decimal   amt  = decimal.Parse(row1.Text);

                EntityLayers.Payment _Pobj = new EntityLayers.Payment()
                {
                    _dateOfPayment = System.DateTime.Now,
                    _paymentMode   = "CARD",
                    _bankName      = txtBankName.Text,
                    _cardType      = txtCardType.Text,
                    _cardNO        = txtCardNumber.Text,
                    _nameOnCard    = txtNameOnCard.Text,
                    _totalamount   = amt
                };

                int result1 = _userObj.InsertInPayment(_tOobj, _Pobj);
                if (result1 == 1)
                {
                    Response.Write("<Script>alert('Payment is Successful')</script>");
                }
                else if (result1 == 0)
                {
                    Response.Write("<Script>alert('Payment Not Successful Check Your details')</script>");
                }
            }
            else
            {
                Response.Write("<Script>alert('Payment Not Successful Check Your details')</script>");
            }
            Response.Redirect("UserHome.aspx");
            SqlConnection _conObj = new SqlConnection("server=.; database=HotelDB; trusted_connection=yes");
            SqlCommand    _cmd1   = new SqlCommand("Truncate table TEMPORDER", _conObj);

            _cmd1.ExecuteNonQuery();
        }