Ejemplo n.º 1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (Decrypt(Request.QueryString["SessionId"]) == sessionvalue[12].ToString() && Session[Decrypt(Request.QueryString["SessionId"])] != "")
        {
            long transid         = 0;
            long refno           = 0;
            TransactionRecord tr = new TransactionRecord();
            try
            {
                #region Session based
                if (Session_value != "" && Request.QueryString["SessionId"] != null)
                {
                    try
                    {
                        string[] strarr;
                        strarr = Session_value.Split(',');
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(string.Format("Transaction [{0}]  ", strarr[12]));
                        tr.BookingID = long.Parse(strarr[12]);
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(string.Format("Seats  " + Session_value));
                        // tr.AgentCode = Session["AgentCode"].ToString();
                        tr.AgentCode   = "Agent-" + Session["Agent"].ToString();
                        tr.Source      = "Web-TicketingAgent";
                        tr.BookingType = "Web-TicketingAgent";
                        //tr.VoucherType = rblVoucher.SelectedValue;
                        //tr.VoucherNo = "";
                        //tr.VoucherBookingID = 0;

                        tr.CardType       = "";
                        tr.PaymentGateway = "Web-TicketingAgent";
                        tr.CardNo         = "1111222233334444";
                        tr.MobileNo       = txtContactNo.Text;
                        tr.Name           = txtName.Text;
                        tr.PaymentType    = "";
                        tr.DateOfBooking  = DateTime.Now.Date.ToShortDateString();
                        // tr.IsProcessed = ;
                        // tr.PaymentStatus = ;
                        tr.router                = "";
                        tr.WantComplimentary     = false;
                        tr.WantComplimentaryDrop = false;
                        tr.PlaceOfDrop           = "";
                        tr.PlaceOfPick           = "";
                        tr.TimeOfPick            = "";
                        tr.TimeOfDrop            = "";
                        tr.EmailID               = txtEmailAddress.Text;
                        tr.Status                = false;
                        tr.TimeOfBooking         = DateTime.Now.ToShortTimeString();
                        tr.TotalSeats            = int.Parse(strarr[5].ToString());
                        tr.Category              = strarr[8];
                        tr.Location              = strarr[6];
                        tr.Play = strarr[1];

                        string[] datarr = strarr[2].ToString().Split('/');//for live server
                        //string[] datarr = strarr[2].ToString().Split('-');// for dev/local

                        tr.ShowDate = datarr[1] + "/" + datarr[0] + "/" + datarr[2];//for live server
                        //tr.ShowDate = datarr[0] + "/" + datarr[1] + "/" + datarr[2]; // for dev/local


                        tr.ShowTime = strarr[7];
                        tr.Day      = Convert.ToDateTime(tr.ShowDate).DayOfWeek.ToString();
                        //tr.ShowDate = datarr[1] + "/" + datarr[0] + "/" + datarr[2];//for local
                        tr.Remark      = "";
                        tr.TotalAmount = GTICKBOL.Get_SeatPrice_SeatKeyNoWise(tr.BookingID);
                        tr.SeatInfo    = SeatVal;
                        tr.Address     = txtAddress.Text.Trim();
                        tr.IP          = GetIP();
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Date : " + tr.DateOfBooking);
                        transid        = TransactionBOL.Transaction_Temp_Insert(tr);
                        tr.ReferenceNo = tr.BookingID;
                        tr.BookingID   = transid;
                        refno          = GTICKBOL.InsertAgentBooking_Details(tr);
                        GTICKV.LogEntry(tr.ReferenceNo.ToString(), "Starting to write Information to temp Session Table", "7", "");
                    }
                    catch (Exception ex)
                    {
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Transaction Preparation Error: " + ex.Message);
                        ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
                    }
                    GTICKV.LogEntry(tr.ReferenceNo.ToString(), "Category : " + tr.Category + " ,Seat Info : " + tr.SeatInfo +
                                    ", Total Amt : " + tr.TotalAmount, "8", "");

                    if (transid > 0 && refno > 0)
                    {
                        Session["AgentCode"] = null;
                        GTICKV.LogEntry(tr.BookingID.ToString(), "Data Successfully Written to Temp Transaction Table", "9", transid.ToString());
                        string    URL = "";
                        DataTable dt  = TransactionBOL.Get_Transaction_Detail(tr);
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            GTICKBOL.Update_AgentBooking(tr.BookingID);
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Payment Redirection: " + URL);
                            Response.Redirect("Print-Receipt.aspx?b=" + tr.BookingID.ToString(), false);
                            Session[Decrypt(Request.QueryString["SessionId"])] = "";
                            bool seatsBooked = (int.Parse(dt.Rows[0]["SeatBooked"].ToString()) > 0);
                            ReceiptUtils.SuccessPaymentResponse(seatsBooked, dt.Rows[0], tr.ReferenceNo.ToString(), tr.BookingID.ToString(), tr.ReceiptNo, "");
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Booking successfull" + tr.ReferenceNo);
                        }
                        else
                        {
                            Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("booking failed" + tr.ReferenceNo);
                            DataTable dt1 = TransactionBOL.Select_Temptransaction_REFIDWISE(tr.ReferenceNo);
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                ReceiptUtils.PaymentNotCaptureResponse(tr.ReceiptNo.ToString(), dt1.Rows[0], "");
                            }
                            if (sessionvalue[12] != null)
                            {
                                String KeyNo = Decrypt(sessionvalue[12]);
                                GTICKBOL.ON_Session_out(KeyNo);
                                Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("seat releasefor:" + KeyNo);
                            }
                            Session.Clear();
                            ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
                        }
                    }
                    else
                    {
                        lblMess.Text = "Session Timeout. Please start the transaction again by clicking \"Back\" button";
                        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Session Timeout. Need to restart transaction");
                        ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
                    }
                }
                else //no Session[seat_val]
                {
                    ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
                }
                #endregion
            }
            catch (Exception ex)
            {
                GTICKV.LogEntry(tr.BookingID.ToString(), "Error Occurred - " + ex.Message.Replace("'", ""), "8", transid.ToString());
                ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
            }
        }
        else
        {
            Session.Clear();
            ClientScript.RegisterStartupScript(GetType(), "myscript", "<script>alert('Session Timeout. Please start the transaction again');window.location.href='Default.aspx';</script>");
        }
    }