/// <summary> /// 保存数据 /// </summary> /// <param name="product">生产厂家实体</param> /// <param name="workId">机构id</param> /// <returns>true成功</returns> public bool SaveProduct(MW_ProductDic product, int workId) { try { Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("ProductName", product.ProductName); dictionary.Add("WorkId", workId.ToString()); DataTable dt = GetProducts(dictionary); //新增有重名数据 if (product.ProductID == 0 && dt.Rows.Count > 0) { return(false); } else if (product.ProductID != 0 && dt.Rows.Count > 0) { if (dt.Select("ProductID=" + product.ProductID).Length == 1 && dt.Rows.Count > 1) { return(false); } if (dt.Select("ProductID=" + product.ProductID).Length == 0 && dt.Rows.Count > 0) { return(false); } } this.BindDb(product); SetWorkId(workId); product.save(); return(true); } catch (Exception) { throw; } }
/// <summary> /// 更新生产商数据 /// </summary> /// <param name="productDic">生产商实体</param> public void UpdateProduct(MW_ProductDic productDic) { productDic.DelFlag = 1; productDic.save(); }