コード例 #1
0
        /// <summary>
        /// Method to validate Card Information
        /// </summary>
        /// <param name="cIObj">Object of CardInfo class</param>
        /// <returns>Returns integer of count of first column retreived depending on mathching condition</returns>
        public int ValidateCardInfo(EntityLayers.CardInfo cIObj)
        {
            SqlConnection _conObj = new SqlConnection("Data Source=.;Initial Catalog=HotelDB;Integrated Security=True");

            try
            {
                string _cardNumber = cIObj._cardNO;
                string _nameOnCard = cIObj._NameOnCard;
                string _bankname   = cIObj._bankName;
                string _cardType   = cIObj._cardType;
                string _expDate    = cIObj._expDate.ToString();
                _conObj.Open();
                string     query = "Select count(*) from CardInfo where [Card NO]='" + _cardNumber + "' and [Name On Card]='" + _nameOnCard + "' and [Card Type]='" + _cardType + "' and [Bank Name]='" + _bankname + "' and [Expiry Date]='" + _expDate + "'";
                SqlCommand _cmd  = new SqlCommand("query", _conObj);
                int        res   = int.Parse(_cmd.ExecuteScalar().ToString());
                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();
        }