private void Delete() { if (GuGuGuHelper.IsInDataGridView(selectRow, DGVProduct)) { string checkSql = "select * from Inventory where ProductID = '" + TbProductID.Text + "'and quantity!=0"; if (!GuGuGuHelper.ExcuteExist(checkSql)) { List <string> sqlList = new List <string>(); { string sql = "delete from dbo.Inventory where ProductID = '" + TbProductID.Text + "'"; sqlList.Add(sql); } { string sql = "delete from dbo.Products where ProductID = '" + TbProductID.Text + "'"; sqlList.Add(sql); } int cnt = GuGuGuHelper.ExecuteNonQueryTransaction(sqlList); if (cnt >= 2) { MessageBox.Show("删除成功"); } else { MessageBox.Show("删除失败"); } } else { MessageBox.Show("该商品已出售或者其他未知错误"); } TextBoxFill(); } }
private void Delete() { if (GuGuGuHelper.IsInDataGridView(selectRow, DGVCategories)) { string id = DGVCategories.Rows[selectRow].Cells["商品类别编号"].Value.ToString(); { string sql = "select * from Products where CategoryID = " + id + "'"; if (GuGuGuHelper.ExcuteExist(sql)) { MessageBox.Show("该类别下含有商品,禁止删除!"); return; } } { string sql = "delete from Categories where CategoryID = '" + id + "'"; int cnt = GuGuGuHelper.ExecuteNonQuery(sql); if (cnt >= 1) { MessageBox.Show("删除成功"); } else { MessageBox.Show("删除失败"); } CateRefresh(); } } else { MessageBox.Show("请选择正确的行"); } }
private void InfoView() { string sql = "select Inventory.ProductID as '商品编号',ProductName as '商品名称' from Products left join Inventory on Products.ProductID=Inventory.ProductID where Products.ThrValue > Inventory.Quantity"; if (!GuGuGuHelper.ExcuteExist(sql)) { LbInfo.Text = "商品告急信息:当前暂无商品缺货"; LbProTip.Text = ""; return; } else { LbProTip.Text = ""; LbInfo.Text = "商品告急信息:以下商品库存紧急,详细信息请到”库存信息 > 商品库存查询“处查看"; } { DataTable table = GuGuGuHelper.ExecuteReaderDataTable(sql); for (int i = 0; i < table.Rows.Count; i++) { LbProTip.Text += "商品编号:" + table.Rows[i]["商品编号"].ToString() + " 商品名称:" + table.Rows[i]["商品名称"].ToString() + "\r\n\r\n"; } } }