Link to home
Start Free TrialLog in
Avatar of HawaiiDragon
HawaiiDragon

asked on

Using a winform to post to a website

Hi experts,

            I am working on  a win form (terminal for a business) that once the user clicks enter it is suposed to post the information to a website with a form action. I know how to do this on a webform but not a winform. Can anyone out there give me a hand please? I have included all code below.
like what i need is
<form action="https://myvirtualmerchant.com/VirtualMerchant/process.do" method="post">
as I said if this was a webform it would not be an issue but it is a win form HELP!!!!!!!
BTW I am using visual studio 2005
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
//using System.Web.Services.Protocols;
using System.Net;
using System.Web.DataAccess;
using System.Web;

namespace VirtualMerchantApp
{
    public partial class Form1 : Form
    {
      

        public Form1()
        {
            InitializeComponent();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (CBTransactionType.Text == "Credit/Debit")
            {
                PCC.Visible = true;
                ECK.Visible = false;
                pnlvoid.Visible = false;
            }

            if (CBTransactionType.Text == "Return")
            {
                PCC.Visible = true;
                ECK.Visible = false;
                pnlvoid.Visible = false;
            }

            if (CBTransactionType.Text == "Void")
            { 
                PCC.Visible = true;
                ECK.Visible = false;
                pnlvoid.Visible = false;
            }

            if (CBTransactionType.Text == "ACH Check")
            {
                PCC.Visible = false;
                ECK.Visible = true;
                pnlvoid.Visible = false;
            }

            if (CBTransactionType.Text == "Void ")
            {
                PCC.Visible = false;
                ECK.Visible = false;
                pnlvoid.Visible = true;
            }
           
        }


        interface IProcessCredit
        {
            string ProcessCheck(DealClass Deal);
            string ProcessCreditCard(DealClass Deal);
            string processCreditReturn(DealClass Deal);
            string processRecurring(DealClass DealId);
            string processVoid(DealClass DealId);
        }

        private void Submit_Click(object sender, EventArgs e)
        {
            _dealInfo.FirstName = TBFirstName.Text;
            _dealInfo.LastName = TBLastName.Text;
            _dealInfo.Address = TBAddress1.Text;
            _dealInfo.City = TBCity.Text;
            _dealInfo.State = TBState.Text;
            _dealInfo.Zip = TBZIP.Text;
            _dealInfo.CCNo = TBCCNumber.Text;
            _dealInfo.CCExpDt= TBCCExpDate.Text;
            _dealInfo.CCSecNo = TBCCNCode.Text;
            _dealInfo.CardType = CBCreditCardType.Text;
            _dealInfo.TransActionType = CBTransactionType.Text;
            _dealInfo.CheckNo = TBCheckNumber.Text;
            _dealInfo.AccountNo = TBBankAccountNumber.Text;
            _dealInfo.RoutingNo = TBBankRoutingNumber.Text;
            _dealInfo.BankName = TBBankName.Text;
            _dealInfo.DealId = 0;
            _dealInfo.PmtNo = 0;

            if (CBTransactionType.Text == "Credit/Debit")
            {
                _dealInfo.FirstName = TBFirstName.Text;
                _dealInfo.LastName = TBLastName.Text;
                _dealInfo.Address = TBAddress1.Text;
                _dealInfo.City = TBCity.Text;
                _dealInfo.State = TBState.Text;
                _dealInfo.Zip = TBZIP.Text;
                _dealInfo.CCNo = TBCCNumber.Text;
                _dealInfo.CCExpDt = TBCCExpDate.Text;
                _dealInfo.CCSecNo = TBCCNCode.Text;
                _dealInfo.CardType = CBCreditCardType.Text;
            }

            if (CBTransactionType.Text == "ACH Check")
            {
                _dealInfo.FirstName = TBFirstName.Text;
                _dealInfo.LastName = TBLastName.Text;
                _dealInfo.Address = TBAddress1.Text;
                _dealInfo.City = TBCity.Text;
                _dealInfo.State = TBState.Text;
                _dealInfo.Zip = TBZIP.Text;
                _dealInfo.CheckNo = TBCheckNumber.Text;
                _dealInfo.AccountNo = TBBankAccountNumber.Text;
                _dealInfo.RoutingNo = TBBankRoutingNumber.Text;
                _dealInfo.BankName = TBBankName.Text;
            }








        }
        private DealClass _dealInfo = new DealClass();

        private CreditLogger _creditInfo = new CreditLogger();
       



    }
}

88888888888888888888888888888888888888888
credit logger
*********************************************
using System;
using System.Data;
using System.Configuration;
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;

/// <summary>
/// Summary description for CreditLogger
/// </summary>
public class CreditLogger
{
    public CreditLogger()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public bool LogTransAction(int DealId,string HtmlResult,int PmtNo,string Check_CCNO,string TransActionNumber,string TransActionCode,string PmtType,string User)
    {
        //credit card must be last 4 only
        return true;
    }




}

***************************************************
iprocess credit
*************************************************
using System;
interface IProcessCredit
{
    string ProcessCheck(DealClass Deal);
    string ProcessCreditCard(DealClass Deal);
    string processCreditReturn(DealClass Deal);
    string processRecurring(DealClass DealId);
    string processVoid(DealClass DealId);
}

Open in new window

Avatar of danirk2
danirk2

Have a look at .Net's WebClient, to be more specifical at WebClient.UploadValues().
Avatar of HawaiiDragon

ASKER

do you have a link?
Just in case you don;t have your MSDN ready, example from there:


Console.Write(ControlChars.Cr + "Please enter the URI to post data to : ")
Dim uriString As String = Console.ReadLine()
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
' Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
Dim myNameValueCollection As New NameValueCollection()
Console.WriteLine("Please enter the following parameters to be posted to the URL:")
Console.Write("Name:")
Dim name As String = Console.ReadLine()

Console.Write("Age:")
Dim age As String = Console.ReadLine()

Console.Write("Address:")
Dim address As String = Console.ReadLine()

' Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("Name", name)
myNameValueCollection.Add("Address", address)
myNameValueCollection.Add("Age", age)

Console.WriteLine(ControlChars.Cr + "Uploading to {0} ...", uriString)
' The Upload(String,NameValueCollection)' method implicitly sets the HTTP POST as the request method.                  
Dim responseArray As Byte() = myWebClient.UploadValues(uriString, myNameValueCollection)

' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :" + ControlChars.Cr + "{0}", Encoding.ASCII.GetString(responseArray))


I dont understand VB. are there any C# examples?
ASKER CERTIFIED SOLUTION
Avatar of danirk2
danirk2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I combined two projects together I built one strickly WEB and then I created a win app to view thie web app and it works preaty good now.

follow this example for the win web viewer.

http://msdn.microsoft.com/en-us/library/360kwx3z.aspx