Esempio n. 1
0
    public string CRCCode(String ClearString, String key, string TRANSACTIONSTATUS, string APTRANSACTIONID, string MESSAGE, string TRANSACTIONID, string AMOUNT)
    {
        try
        {
            Crc32  crc32   = new Crc32();
            String hash    = String.Empty;
            byte[] mybytes = Encoding.UTF8.GetBytes(ClearString);
            foreach (byte b in crc32.ComputeHash(mybytes))
            {
                hash += b.ToString("x2");
            }
            UInt32 Output  = UInt32.Parse(hash, System.Globalization.NumberStyles.HexNumber);
            UInt32 Output1 = UInt32.Parse(key);

            if (Output1 == Output)
            {
                if (Session["Hotel"] != null)
                {
                    lblTotPaid.Text = Convert.ToDouble(AMOUNT).ToString("#.##");

                    GenrateBill1(TRANSACTIONID);
                    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ReservationConnectionString"].ConnectionString);
                    con.Open();
                    SqlCommand cmd           = new SqlCommand("insert into tblTransactionDetails values('" + hfBookingId.Value + "', '" + TRANSACTIONID + "','" + APTRANSACTIONID + "' , '" + Convert.ToDecimal(AMOUNT) + "','" + TRANSACTIONSTATUS + "','" + System.DateTime.Now + "')", con);
                    int        QueryResponse = cmd.ExecuteNonQuery();

                    con.Close();
                    if (QueryResponse > 0)
                    {
                        // lbBookingNo.Text = TRANSACTIONID.ToString();
                        //FiilPackage();
                    }
                }
                else
                {
                    lblTotPaid.Text = Convert.ToDouble(AMOUNT).ToString("#.##");;

                    GenrateBill(TRANSACTIONID);
                    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ReservationConnectionString"].ConnectionString);
                    con.Open();
                    SqlCommand cmd           = new SqlCommand("insert into tblTransactionDetails values('" + hfBookingId.Value + "', '" + TRANSACTIONID + "','" + APTRANSACTIONID + "' , '" + Convert.ToDecimal(AMOUNT) + "','" + TRANSACTIONSTATUS + "','" + System.DateTime.Now + "')", con);
                    int        QueryResponse = cmd.ExecuteNonQuery();
                    con.Close();
                    if (QueryResponse > 0)
                    {
                        // lbBookingNo.Text = TRANSACTIONID.ToString();
                        FiilPackage();
                    }
                    DataTable GridRoomPaxDetail = SessionServices.RetrieveSession <DataTable>("BookedRooms");

                    gdvCruiseRooms.FooterRow.Cells[1].Text = "Total </br> Service Tax @ 4.50% </br> <b> Grand Total </b>";
                    gdvCruiseRooms.FooterRow.Cells[3].Text = Math.Round(Convert.ToDouble(GridRoomPaxDetail.Compute("SUM(Price)", string.Empty))).ToString("#.##") + "</br> " + Math.Round((4.5 * (Convert.ToInt32(GridRoomPaxDetail.Compute("SUM(Price)", string.Empty)) / 100))).ToString("#.##") + " </br> " + Math.Round((Convert.ToDouble(GridRoomPaxDetail.Compute("SUM(Price)", string.Empty)) + (4.5 * (Convert.ToInt32(GridRoomPaxDetail.Compute("SUM(Price)", string.Empty)) / 100)))).ToString("#.##");
                    lblTotAMt.Text      = Math.Round((Convert.ToDouble(GridRoomPaxDetail.Compute("SUM(Price)", string.Empty)) + (4.5 * (Convert.ToInt32(GridRoomPaxDetail.Compute("SUM(Price)", string.Empty)) / 100)))).ToString("#.##");
                    lblBalance.Text     = Math.Round((Convert.ToDouble(lblTotAMt.Text) - Convert.ToDouble(lblTotPaid.Text))).ToString("#.##");
                    lbBalanceDueIn.Text = Convert.ToDateTime(lblArrvDate.Text).AddDays(-90).ToString("d MMMM, yyyy");

                    //gdvCruiseRooms.FooterRow.Cells[1].Text = "Total </br> Service Tax @ 4.50%";
                    //gdvCruiseRooms.FooterRow.Cells[3].Text = Convert.ToDouble(GridRoomPaxDetail.Compute("SUM(Price)", string.Empty)).ToString();
                    //lblTotAMt.Text = (Convert.ToDouble(GridRoomPaxDetail.Compute("SUM(Price)", string.Empty)) + (4.5 * (Convert.ToInt32(GridRoomPaxDetail.Compute("SUM(Price)", string.Empty)) / 100))).ToString();
                    //lblBalance.Text = (Convert.ToDouble(lblTotAMt.Text) - Convert.ToDouble(lblTotPaid.Text)).ToString();


                    Session["BookedRooms"] = null;
                    Session["PackageId"]   = null;
                    Session["BookingRef"]  = null;
                }
                lbRuppeeinwords.Text = GF.NumbersToWords(Convert.ToInt32(lblTotAMt.Text));
            }
            else
            {
                Response.Write("Secure Hash mismatch.");
            }
            return(hash);
        }
        catch
        {
            return(null);
        }
    }