Zakir Ahamed

Zakir Ahamed

  • NA
  • 1.4k
  • 610k

i had prblm to setting alert for listbox in windows forms

Aug 2 2017 1:19 AM
hi friends ,
 
i had a problem to setting a listbox alert error provider problem..
 
my code is:
 
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());
if (string.IsNullOrEmpty(cbbrand.Text))
{
errorProvider7.SetError(cbbrand, "Please enter Product Price");
hstbl.Add("@BrandId", cbbrand.SelectedValue);
return;
}
else
{
errorProvider7.SetError(cbbrand, string.Empty);
}
if (string.IsNullOrEmpty(cbunit.Text))
{
errorProvider8.SetError(cbbrand, "Please enter Product Price");
hstbl.Add("@Unit", cbunit.SelectedValue);
return;
}
else
{
errorProvider8.SetError(cbbrand, string.Empty);
}
hstbl.Add("@ReceivedQuantity", txtquantity.Text.Trim());
if (string.IsNullOrEmpty(cbcategory.Text))
{
errorProvider9.SetError(cbbrand, "Please enter Product Price");
hstbl.Add("@CategoryId", cbcategory.SelectedValue);
return;
}
else
{
errorProvider9.SetError(cbbrand, string.Empty);
}
if (string.IsNullOrEmpty(cblevel1.Text))
{
errorProvider10.SetError(cbbrand, "Please enter Product Price");
hstbl.Add("@SubCategoryId", cblevel1.SelectedValue);
return;
}
else
{
errorProvider10.SetError(cbbrand, string.Empty);
}
if (string.IsNullOrEmpty(cblevel2.Text))
{
errorProvider11.SetError(cbbrand, "Please enter Product Price");
hstbl.Add("@SubsSubCategoryId", cblevel2.SelectedValue);
return;
}
else
{
errorProvider11.SetError(cbbrand, string.Empty);
}
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();
}
 
how i will set a alert with error or any other option ..
 
because of with out alert my db throwing error message duplicate null values is not allowed..
 

Answers (1)