本文整理汇总了C#中Product.isValid方法的典型用法代码示例。如果您正苦于以下问题:C# Product.isValid方法的具体用法?C# Product.isValid怎么用?C# Product.isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.isValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnproUpdate_Click
private void btnproUpdate_Click(object sender, EventArgs e)
{
if (this.txtproID.Text.Equals(""))
{
MessageBox.Show("You should select an Product first.");
return;
}
try
{
Product updateData = new Product();
updateData.ProductID = int.Parse(this.txtproID.Text.Trim());
updateData.ProductName = this.txtproName.Text;
updateData.SupplierID = int.Parse(this.cbxSupID.Text);
updateData.CategoryID = int.Parse(this.cbxCaID.Text);
updateData.UnitPrice = this.txtUnitprice.Text;
updateData.Discontinued = this.cbDiscontinued.Checked;
int check = updateData.isValid();
if (check < -1)
{
MessageBox.Show("You should select an Product first.");
return;
}
else
{
//int IdOfRow = this.gvCategories.Rows.IndexOf(this.gvCategories.SelectedRows[0]);
this.dataModel.updateRow(updateData);
MessageBox.Show("Updated.");
clearAll();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例2: btnproAdd_Click
private void btnproAdd_Click(object sender, EventArgs e)
{
Product newPro = new Product();
newPro.ProductID = -1;
newPro.ProductName = txtproName.Text;
try
{
newPro.SupplierID = int.Parse(cbxSupID.Text);
newPro.CategoryID = int.Parse(cbxCaID.Text);
}
catch { MessageBox.Show("SupplierID or CatogoryID isValid");
}
newPro.UnitPrice = txtUnitprice.Text;
newPro.Discontinued = this.cbDiscontinued.Checked;
int check = newPro.isValid();
if (check < -1)
{
MessageBox.Show(newPro.getErrorMessage(check));
}
else
{
this.dataModel.insertNewRow(newPro);
//this.datamodel.resetControl();
MessageBox.Show("Completed");
clearAll();
}
}
示例3: doAdd_Update
protected void doAdd_Update(bool add)
{
Product dataObj = new Product();
dataObj.ProductID = -1;
dataObj.ProductName = txtproName.Text;
try
{
dataObj.SupplierID = ((ProductModel.IdItem) cbxSupID.SelectedItem).Id;
dataObj.CategoryID = ((ProductModel.IdItem) cbxCaID.SelectedItem).Id;
}
catch
{
MessageBox.Show("SupplierID or CatogoryID isValid");
return;
}
try
{
dataObj.UnitPrice = float.Parse(txtUnitprice.Text);
}
catch
{
MessageBox.Show("INVALID VALUE FOR UNIT PRICE");
return;
}
dataObj.Discontinued = this.cbDiscontinued.Checked;
int check = dataObj.isValid();
if (check < -1)
{
MessageBox.Show(dataObj.getErrorMessage(check));
}
else
{
if (add == true)
this.dataModel.insertNewRow(dataObj);
else
{
dataObj.ProductID = int.Parse(this.txtproID.Text);
this.dataModel.updateRow(dataObj);
}
//this.datamodel.resetControl();
MessageBox.Show("Completed");
clearAll();
}
}