hi all,
I am making an application that generates P.O automatically after entering all the details prices, taxes, descriptions ..
I have used the following code for retrieving the the float type amounts.
Double Price1 = 0;
bool isPrice1Valid = false;
isPrice1Valid = Double.TryParse(TextBox8.Text, out Price1);
if (!string.IsNullOrEmpty(TextBox8.Text) && !isPrice1Valid)
{
// this is the case when user enterted a wrong value in the box
// you can show you user a message that price in in valid here
ErrorLabel.Text = "Please enter valid Price , it must be numeric";
return;
}
Double Qty1 = 0;
bool isQty1Valid = false;
isQty1Valid = Double.TryParse(TextBox9.Text, out Qty1);
if (!string.IsNullOrEmpty(TextBox9.Text) && !isQty1Valid)
{
// this is the case when user enterted a wrong value in the box
// you can show you user a message that price in in valid here
ErrorLabel.Text = "Please enter valid Quantity, it must be numeric";
return;
}
double Product1 = (Price1) * (Qty1);
TextBox10.Text = (Product1 == 0) ? "" : Product1.ToString();
//Double Total = Convert.ToDouble(TextBox5.Text);
Double Total1 = 0;
bool isTotal1Valid = false;
isTotal1Valid = Double.TryParse(TextBox154.Text, out Total1);
if (!string.IsNullOrEmpty(TextBox154.Text) && !isTotal1Valid)
{
// this is the case when user enterted a wrong value in the box
// you can show you user a message that price in in valid here
ErrorLabel.Text = "Please enter valid Tax Total, it must be numeric";
return;
}
Double Total31 = 0;
bool isTotal31Valid = false;
isTotal31Valid = Double.TryParse(TextBox164.Text, out Total31);
if (!string.IsNullOrEmpty(TextBox164.Text) && !isTotal31Valid)
{
// this is the case when user enterted a wrong value in the box
// you can show you user a message that price in in valid here
ErrorLabel.Text = "Please enter valid Tax Total, it must be numeric";
return;
}
Double Total41 = 0;
bool isTotal41Valid = false;
isTotal41Valid = Double.TryParse(TextBox215.Text, out Total41);
if (!string.IsNullOrEmpty(TextBox215.Text) && !isTotal41Valid)
{
// this is the case when user enterted a wrong value in the box
// you can show you user a message that price in in valid here
ErrorLabel.Text = "Please enter valid Tax Total, it must be numeric";
return;
}
Double Total51 = 0;
bool isTotal51Valid = false;
isTotal51Valid = Double.TryParse(TextBox225.Text, out Total51);
if (!string.IsNullOrEmpty(TextBox225.Text) && !isTotal51Valid)
{
// this is the case when user enterted a wrong value in the box
// you can show you user a message that price in in valid here
ErrorLabel.Text = "Please enter valid Tax Total, it must be numeric";
return;
}
Double Total61 = 0;
bool isTotal61Valid = false;
isTotal61Valid = Double.TryParse(TextBox235.Text, out Total61);
if (!string.IsNullOrEmpty(TextBox235.Text) && !isTotal61Valid)
{
// this is the case when user enterted a wrong value in the box
// you can show you user a message that price in in valid here
ErrorLabel.Text = "Please enter valid Tax Total, it must be numeric";
return;
}
//Double DiscountPercentage = Convert.ToDouble(TextBox4.Text);
Double DiscountPercentage1 = 0;
bool isDiscountPercentage1Valid = false;
isDiscountPercentage1Valid = Double.TryParse(TextBox10.Text, out DiscountPercentage1);
if (!string.IsNullOrEmpty(TextBox10.Text) && !isDiscountPercentage1Valid)
{
// this is the case when user enterted a wrong value in the box
// you can show you user a message that price in in valid here
ErrorLabel.Text = "Please enter valid Amount , it must be numeric";
return;
}
double Discount1 = ((Total1) * (DiscountPercentage1)) / 100;
TextBox12.Text = (Discount1 == 0) ? "" : Discount1.ToString();
double Discount31 = ((Total31) * (DiscountPercentage1)) / 100;
TextBox174.Text = (Discount31 == 0) ? "" : Discount31.ToString();
double Discount41 = ((Total41) * (DiscountPercentage1)) / 100;
TextBox184.Text = (Discount41 == 0) ? "" : Discount41.ToString();
double Discount51 = ((Total51) * (DiscountPercentage1)) / 100;
TextBox195.Text = (Discount51 == 0) ? "" : Discount51.ToString();
double Discount61 = ((Total61) * (DiscountPercentage1)) / 100;
TextBox205.Text = (Discount61 == 0) ? "" : Discount61.ToString();
double total_Amount1 = Discount1 + Product1 + Discount31 + Discount41 + Discount51 + Discount61;
TextBox13.Text = (total_Amount1 == 0) ? "" : total_Amount1.ToString();
Double Price2 = 0;
bool isPrice2Valid = false;
isPrice2Valid = Double.TryParse(TextBox22.Text, out Price2);
if (!string.IsNullOrEmpty(TextBox22.Text) && !isPrice2Valid)
{
// this is the case when user enterted a wrong value in the box
// you can show you user a message that price in in valid here
ErrorLabel.Text = "Please enter valid Price , it must be numeric";
return;
}
The data in the databse takes null values which are left over while submitting the values..as in the empty textboxes are saving as zeros..
it is atchually a mess when data is retrieved.
i retrieve the data using this code
TextBox10.Text = reader["Amount11"].ToString();
TextBox24.Text = reader["Amount12"].ToString();
TextBox31.Text = reader["Amount13"].ToString();
TextBox38.Text = reader["Amount14"].ToString();
TextBox45.Text = reader["Amount15"].ToString();
TextBox52.Text = reader["Amount16"].ToString();
TextBox59.Text = reader["Amount17"].ToString();
TextBox66.Text = reader["Amount18"].ToString();
TextBox83.Text = reader["Amount19"].ToString();
TextBox73.Text = reader["Amount20"].ToString();
TextBox78.Text = reader["Grand_Amount11"].ToString();
TextBox154.Text = reader["Total_Tax_Perc11"].ToString();
TextBox155.Text = reader["Total_Tax_Perc12"].ToString();
TextBox156.Text = reader["Total_Tax_Perc13"].ToString();
TextBox157.Text = reader["Total_Tax_Perc14"].ToString();
TextBox158.Text = reader["Total_Tax_Perc15"].ToString();
Please tell me what can be the solution.