using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class Status : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string MERCHANTNUMBER = Request["MERCHANTNUMBER"];
        string ORDERNUMBER = Request["ORDERNUMBER"];
        string COMMTYPE = Request["COMMTYPE"];
        string CURRENTSTATE = Request["CURRENTSTATE"];
        string PREVIOUSSTATE = Request["PREVIOUSSTATE"];
        string PAYMENTTYPE = Request["PAYMENTTYPE"];
        string EVENTTYPE = Request["EVENTTYPE"];
        string PAYMENTNUMBER = Request["PAYMENTNUMBER"];
        string APPROVALCODE = Request["APPROVALCODE"];
        string VALIDATIONCODE = Request["VALIDATIONCODE"];
        string BIN = Request["BIN"];
        string AUTHTIME = Request["AUTHTIME"];
        string TYPE = Request["TYPE"];
        string WITHCVC = Request["WITHCVC"];

        string connString = ConfigurationManager.ConnectionStrings["BazaReklamConn"].ConnectionString;
        string cmdText = "insert into PotwierdzeniaEcard(MERCHANTNUMBER, ORDERNUMBER, COMMTYPE, CURRENTSTATE, PREVIOUSSTATE, PAYMENTTYPE, EVENTTYPE, PAYMENTNUMBER, APPROVALCODE, VALIDATIONCODE, BIN, AUTHTIME, TYPE, WITHCVC) values (@MERCHANTNUMBER, @ORDERNUMBER, @COMMTYPE, @CURRENTSTATE, @PREVIOUSSTATE, @PAYMENTTYPE, @EVENTTYPE, @PAYMENTNUMBER, @APPROVALCODE, @VALIDATIONCODE, @BIN, @AUTHTIME, @TYPE, @WITHCVC)";
        using (SqlConnection conn = new SqlConnection(connString))
        {
            try
            {
                SqlCommand cmd = new SqlCommand(cmdText, conn);
                cmd.Parameters.Add("@MERCHANTNUMBER", SqlDbType.VarChar, 50).Value = MERCHANTNUMBER;
                int iORDERNUMBER = Convert.ToInt32(ORDERNUMBER);
                cmd.Parameters.Add("@ORDERNUMBER", SqlDbType.Int).Value = iORDERNUMBER;
                cmd.Parameters.Add("@COMMTYPE", SqlDbType.VarChar, 50).Value = COMMTYPE;
                cmd.Parameters.Add("@CURRENTSTATE", SqlDbType.VarChar, 50).Value = CURRENTSTATE;
                cmd.Parameters.Add("@PREVIOUSSTATE", SqlDbType.VarChar, 50).Value = PREVIOUSSTATE;
                int iPAYMENTTYPE = Convert.ToInt32(PAYMENTTYPE);
                cmd.Parameters.Add("@PAYMENTTYPE", SqlDbType.Bit).Value = iPAYMENTTYPE;
                int iEVENTTYPE = Convert.ToInt32(EVENTTYPE);
                cmd.Parameters.Add("@EVENTTYPE", SqlDbType.Bit).Value = iEVENTTYPE;
                int iPAYMENTNUMBER = Convert.ToInt32(PAYMENTNUMBER);
                cmd.Parameters.Add("@PAYMENTNUMBER", SqlDbType.Bit).Value = iPAYMENTNUMBER;
                cmd.Parameters.Add("@APPROVALCODE", SqlDbType.VarChar, 50).Value = APPROVALCODE;
                cmd.Parameters.Add("@VALIDATIONCODE", SqlDbType.Char, 3).Value = VALIDATIONCODE;
                cmd.Parameters.Add("@BIN", SqlDbType.Char, 6).Value = BIN;
                DateTime dtAUTHTIME = Convert.ToDateTime(AUTHTIME);
                cmd.Parameters.Add("@AUTHTIME", SqlDbType.DateTime).Value = dtAUTHTIME;
                cmd.Parameters.Add("@TYPE", SqlDbType.Char, 2).Value = TYPE;
                cmd.Parameters.Add("@WITHCVC", SqlDbType.Char, 3).Value = WITHCVC;
                conn.Open();
                cmd.ExecuteNonQuery();
                Response.Write("OK");                
            }
            catch
            {
                Response.Write("FALSE");                
            }
            finally
            {
                conn.Close();
            }
        }
        
    }
}
