Click here to Skip to main content
16,007,885 members

Comments by aspkiddy (Top 5 by date)

aspkiddy 1-Feb-11 16:49pm View    
How I can declare it at the top of the method ?

public partial class ConfirmationDonationForm : System.Web.UI.Page { private FormConfirmationPageState mFormConfirmationPageState; string cost; //!!!!!!!!!!!!!!!!!!!! int newVal; //!!!!!!!!!!!!!!!!!!!!

aspkiddy 1-Feb-11 15:30pm View    
Hi Nishant Sivakumar,

how can i declare it on top of the method ? which method ?
namespace TotoCommerce
{
///
/// Summary description for DonationForm.
///

public partial class ConfirmationDonationForm : System.Web.UI.Page
{
private FormConfirmationPageState mFormConfirmationPageState;

string cost; //!!!!!!!!!!!!!!!!!!!!
int newVal; //!!!!!!!!!!!!!!!!!!!!




protected void Page_Load(object sender, System.EventArgs e)
{
LoadPageState();
LoadLabels();


}

private void LoadPageState()
{
object pageState = Session["FormConfirmationPage"];
if (pageState != null)
{
mFormConfirmationPageState = (FormConfirmationPageState)pageState;
}
else
{
}
}

private void SavePageState()
{
Session["FormConfirmationPage"] = mFormConfirmationPageState;
}


private void LoadLabels()
{
object FormPageState = Session["FormPage"];
DonationForm.FormPageState s = (DonationForm.FormPageState)FormPageState;


mPrenomNomLabel.Text = s.FirstName + " " + s.LastName;


mAmountLabel.Text = s.AmountContribution; //!!!!!!!!!!!!!!!!!!!! 22.00



cost = s.AmountContribution;
double doubleVal = 0.0;
if (Double.TryParse(cost, out doubleVal))
{
int newVal = (int)doubleVal * 100;
mAmountLabel.Text = newVal.ToString();//!!!!!!!!!!!!!!!!!!!! 2200
// save this value

}




protected void SubscribeButton_Click(object sender, System.EventArgs e)
{
SubscribeButton.Enabled = false;
ButtonRectifier0.Enabled = false;
string strFacturation;

strFacturation = (string)Session["Facturation"];


if (strFacturation != "EnCours")
{


Session["Facturation"] = "EnCours";

object FormPageState = Session["FormPage"];
DonationForm.FormPageState s = (DonationForm.FormPageState)FormPageState;
string strParametre = "0?,A1" + newVal.ToString() + ",DT" + DateTime.Now.ToString("MMddyyyyHHmm"); //!!!!!!!!!!!!!!!!!!!! 0
aspkiddy 1-Feb-11 14:43pm View    
How I cant use easily Decimal to store the prices ?
aspkiddy 1-Feb-11 14:42pm View    
Hi Nishant,

It's work with

mPriceLabel.Text = newVal.ToString();

I see 2200 on mPriceLabel


it's great

How I can remove [If condition] ?

Beacouse I must sent this information on transaction serveur :


If I use :

string cost = s.AmountContribution;
double doubleVal = 0.0;
if (Double.TryParse(cost, out doubleVal))
{
int newVal = (int)doubleVal * 100;
//mPriceLabel.Text = newVal.ToString();


}




string strParametre = "0?,A1" + newVal.ToString() + ",DT" + DateTime.Now.ToString("MMddyyyyHHmm"); //line 223




I have this error :



Compiler Error Message: CS0103: The name 'newVal' does not exist in the current context : line 223

aspkiddy 1-Feb-11 14:24pm View    
Hi,

Now What I do ?


My code as like your code :

1st screen :

private void SetPageState()
{
int amountInt = int.Parse(mamountTextBox.Text);
mFormPageState.AmountContribution = amountInt.ToString("0.00");
SavePageState();
}

public struct FormPageState
{
public int amountInt;
public string AmountContribution;
}


and 2nd screen :

//(...)

mAmountLabel.Text = s.AmountContribution; // for user for exemple : 22.00

string cost = s.AmountContribution;
double doubleVal = 0.0;
if (Double.TryParse(cost, out doubleVal))
{
int newVal = (int)doubleVal * 100;
mPriceLabel.Text = newVal; // for check il I have 2200 or ...

}