[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 460
  • Last Modified:

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

0
HawaiiDragon
Asked:
HawaiiDragon
  • 3
  • 3
1 Solution
 
danirk2Commented:
Have a look at .Net's WebClient, to be more specifical at WebClient.UploadValues().
0
 
HawaiiDragonAuthor Commented:
do you have a link?
0
 
danirk2Commented:
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))


0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
HawaiiDragonAuthor Commented:
I dont understand VB. are there any C# examples?
0
 
danirk2Commented:
Console.Write("\nPlease enter the URI to post data to : ");
string uriString = Console.ReadLine();

// Create a new WebClient instance.
WebClient myWebClient = new WebClient();

// Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
NameValueCollection myNameValueCollection = new NameValueCollection();

Console.WriteLine("Please enter the following parameters to be posted to the URL");
Console.Write("Name:");
string name = Console.ReadLine();

Console.Write("Age:");
string age = Console.ReadLine();

Console.Write("Address:");
string address = 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("\nUploading to {0} ...",  uriString);
// 'The Upload(String,NameValueCollection)' implicitly method sets HTTP POST as the request method.            
byte[] responseArray = myWebClient.UploadValues(uriString,myNameValueCollection);

// Decode and display the response.
Console.WriteLine("\nResponse received was :\n{0}",Encoding.ASCII.GetString(responseArray));


0
 
HawaiiDragonAuthor Commented:
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now