Zakir Ahamed

Zakir Ahamed

  • NA
  • 1.4k
  • 627.5k

i have prblm to alert textbox all fields onen by one

Jul 27 2017 5:25 AM
hi friends
 
i have a prblm to validate all text box from windows form but its not working
 
this is my code:
 
private void btnsave_Click(object sender, EventArgs e)
{
try
{
if (txtpname.Text != String.Empty || txtquantity.Text != String.Empty || txtinternal.Text != String.Empty || txtprice.Text != String.Empty || txtpurchase.Text != String.Empty)
{
if (txtquantity.Text == String.Empty)
{
errorProvider3.SetError(txtquantity, "enter Quantity");
// errorProvider3.Clear();
}
else
{
errorProvider3.Clear();
}
if (txtinternal.Text == String.Empty)
{
errorProvider2.SetError(txtinternal, "enter internal no");
// errorProvider2.Clear();
}
else
{
errorProvider2.Clear();
}
if (txtprice.Text == String.Empty)
{
errorProvider4.SetError(txtprice, "enter Price");
// errorProvider4.Clear();
}
else
{
errorProvider4.Clear();
}
if (txtpurchase.Text == String.Empty)
{
errorProvider1.SetError(txtpurchase, "enter Purchase No");
// errorProvider1.Clear();
}
else
{
errorProvider1.Clear();
}
if (btnsave.Text == "SAVE")
{
Hashtable hstbl = new Hashtable();
hstbl.Add("@status", "insert");
hstbl.Add("@ProductNo", txtproduct.Text.Trim());
hstbl.Add("@ProductName", txtpname.Text.Trim());
// hstbl.Add("@BarcodeNo", txtbarcode.Text.Trim());
hstbl.Add("@InternalNo", txtinternal.Text.Trim());
hstbl.Add("@BrandId", cbbrand.SelectedValue);
hstbl.Add("@Unit", cbunit.SelectedValue);
hstbl.Add("@ReceivedQuantity", txtquantity.Text.Trim());
hstbl.Add("@CategoryId", cbcategory.SelectedValue);
hstbl.Add("@SubCategoryId", cblevel1.SelectedValue);
hstbl.Add("@SubsSubCategoryId", cblevel2.SelectedValue);
hstbl.Add("@WarehousePrice", txtwsprice.Text.Trim());
hstbl.Add("@ResalePrice", txtrsprice.Text.Trim());
hstbl.Add("@fprice", txtfsprice.Text.Trim());
hstbl.Add("@price", txtprice.Text.Trim());
hstbl.Add("@createdby", Global.UserID);
Int64 intidentity = DataAccessLayer.ExecuteCommand_RowsAffected("Product_Mst_sp", hstbl);
if (intidentity >= 0)
{
MessageBox.Show("Product Details Saved Sucessfully", "Product Alert");
// clear();
//bind();
loadproduct();
//bindgrid();
//bind();
}
}
else if (btnsave.Text == "Update")
{
Hashtable hstbl = new Hashtable();
DataGridViewRow row = Gvproduct.Rows[indexRow];
hstbl.Add("@status", "update");
hstbl.Add("@ProductNo", txtproduct.Text.Trim());
hstbl.Add("@ProductName", txtpname.Text.Trim());
//hstbl.Add("@BarcodeNo", txtbarcode.Text.Trim());
hstbl.Add("@InternalNo", txtinternal.Text.Trim());
hstbl.Add("@BrandId", cbbrand.SelectedValue);
hstbl.Add("@Unit", cbunit.SelectedValue);
hstbl.Add("@CategoryId", cbcategory.SelectedValue);
hstbl.Add("@SubCategoryId", cblevel1.SelectedValue);
hstbl.Add("@SubsSubCategoryId", cblevel2.SelectedValue);
hstbl.Add("@WarehousePrice", txtwsprice.Text.Trim());
hstbl.Add("@ResalePrice", txtrsprice.Text.Trim());
hstbl.Add("@fprice", txtfsprice.Text.Trim());
hstbl.Add("@Price", txtprice.Text.Trim());
hstbl.Add("@updatedby", Global.UserID);
hstbl.Add("@ProductId", row.Cells[1].Value);
Int64 intidentity = DataAccessLayer.ExecuteCommand_RowsAffected("Product_Mst_sp", hstbl);
if (intidentity >= 0)
{
MessageBox.Show("Product Details Updated Sucessfully", "Product Alert");
clear();
//bind();
loadproduct();
//bindgrid();
btnsave.Text = "SAVE";
}
}
}
else
{
MessageBox.Show("Please Enter the Product Details");
}
}
catch (Exception exceptionObj)
{
MessageBox.Show(exceptionObj.Message.ToString());
}
}
 
 
how i will validate it
 
 
this is my screen... 

Answers (2)