/// <summary> /// 保存一条kitting Code的记录数据(Add), 若Code与相同Type存在记录的Code的名称相同,则提示业务异常 /// </summary> /// <param name="obj">KittingCodeDef结构</param> public void AddKittingCode(KittingCodeDef obj) { try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); //Code与相同Type存在记录的Code的名称相同,则提示业务异常 DataTable exists = itemRepository.GetExistLabelKittingCode(obj.Code, obj.Type); if (exists != null && exists.Rows.Count > 0) { List<string> erpara = new List<string>(); FisException ex; ex = new FisException("DMT081", erpara); throw ex; } LabelKittingCode newItem = new LabelKittingCode(); newItem.code = obj.Code; newItem.editor = obj.Editor; newItem.descr = obj.Descr; newItem.remark = obj.Remark; newItem.type = obj.Type; itemRepository.AddLabelKittingCode(newItem); } catch (Exception) { throw; } }
/// <summary> /// 根据Type取得对应的Kitting Code数据的list(按Code栏位排序) /// </summary> /// <param name="type">过滤条件Type</param> /// <returns></returns> public IList<KittingCodeDef> GetKittingCodeList(string type){ List<KittingCodeDef> retLst = new List<KittingCodeDef>(); try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); IList<LabelKittingCode> getData = itemRepository.GetLabelKittingCodeListByType(type); if (getData != null) { for (int i = 0; i < getData.Count; i++) { LabelKittingCode data = getData[i]; KittingCodeDef item = new KittingCodeDef(); item.Code = data.code; item.Descr = data.descr; item.Type = data.type; item.Remark = data.remark; item.Editor = data.editor; if (data.cdt == DateTime.MinValue) { item.Cdt = ""; } else { item.Cdt = ((System.DateTime)data.cdt).ToString("yyyy-MM-dd HH:mm:ss"); } if (data.udt == DateTime.MinValue) { item.Udt = ""; } else { item.Udt = ((System.DateTime)data.udt).ToString("yyyy-MM-dd HH:mm:ss"); } retLst.Add(item); } } return retLst; } catch (Exception) { throw; } }
//IF EXISTS(SELECT * FROM [IMES_FA].[dbo].[KittingCode] WHERE Code = @Code AND [Type] = 'Kitting') // UPDATE [IMES_FA].[dbo].[KittingCode] // SET Descr = @Description,Remark = @Remark,Editor = @Remark,Udt = GETDATE() // WHERE Code = @Code AND [Type] = 'Kitting' ELSE INSERT INTO [IMES_FA].[dbo].[KittingCode] //([Code],[Type],[Descr],[Remark],[Editor],[Cdt],[Udt]) VALUES(@Code, 'Kitting', @Description, @Remark, @Editor, GETDATE(), GETDATE()) public void SaveKittingCode(KittingCodeDef item) { try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); KittingCode newItem = new KittingCode(); newItem.Code = item.Code; newItem.Editor = item.Editor; newItem.Descr = item.Descr; newItem.Remark = item.Remark; newItem.Type = "Kitting"; itemRepository.SaveKittingCode(newItem); } catch (Exception) { throw; } }
/// <summary> /// 删除一条Kitting Code的记录数据 /// </summary> /// <param name="obj">KittingCodeDef结构</param> public void DeleteKittingCode(KittingCodeDef obj) { try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); itemRepository.RemoveLabelKittingCode(obj.Code, obj.Type); } catch (Exception) { throw; } }
/// <summary> /// 保存一条kitting Code的记录数据(update), 若Code与相同Type存在记录的Code的名称相同,则提示业务异常 /// </summary> /// <param name="obj">更新KittingCodeDef结构</param> /// <param name="oldCode">修改前Code</param> public void UpdateKittingCode(KittingCodeDef obj, string oldCode) { try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); //Code与相同Type存在记录的Code的名称相同,则提示业务异常 DataTable exists = itemRepository.GetExistLabelKittingCode(obj.Code, obj.Type); if (exists != null && exists.Rows.Count > 0 && oldCode != obj.Code) { List<string> erpara = new List<string>(); FisException ex; ex = new FisException("DMT081", erpara); throw ex; } LabelKittingCode itemOld = itemRepository.FindLabelKittingCode(oldCode, obj.Type); if (itemOld == null) { List<string> erpara = new List<string>(); FisException ex; ex = new FisException("DMT082", erpara); throw ex; } LabelKittingCode newItem = new LabelKittingCode(); newItem.code = obj.Code; newItem.editor = obj.Editor; newItem.descr = obj.Descr; newItem.remark = obj.Remark; newItem.type = obj.Type; newItem.cdt = DateTime.Now; //Convert.ToDateTime(obj.Cdt); itemRepository.ChangeLabelKittingCode(newItem, oldCode, obj.Type); } catch (Exception) { throw; } }
//INSERT INTO [IMES_FA].[dbo].[KittingCode] // ([Code],[Type],[Descr],[Remark],[Editor],[Cdt],[Udt]) VALUES(@Code, 'Kitting', //@Description, @Remark, @Editor, GETDATE(), GETDATE()) public string AddKittingCode(KittingCodeDef item) { string result = ""; try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); Boolean isExistKittingCode=itemRepository.IsKittingCodeExist(item.Code); if (isExistKittingCode == true) { //已经存在具有相同Code, 类型为Kitting的KittingCode记录 //!!!need change List<string> erpara = new List<string>(); FisException ex; ex = new FisException("DMT052", erpara); throw ex; } KittingCode newItem = new KittingCode(); newItem.Code = item.Code; newItem.Editor = item.Editor; newItem.Descr = item.Descr; newItem.Remark = item.Remark; newItem.Type = "Kitting"; newItem.Cdt = DateTime.Now; newItem.Udt = DateTime.Now; itemRepository.AddKittingCode(newItem); result = newItem.Code.ToString(); } catch (Exception) { throw; } return result; }
protected void btnDelete_ServerClick(Object sender, EventArgs e) { string oldCode = this.dOldCode.Value.Trim(); string type = this.cmbKittingCodeType.InnerDropDownList.SelectedValue; try { KittingCodeDef item = new KittingCodeDef(); item.Code = oldCode; item.Type = type; iKittingCodeMaintain.DeleteKittingCode(item); } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } ShowListByType(); this.updatePanel2.Update(); ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "DeleteComplete();DealHideWait();", true); }
protected void btnAdd_ServerClick(Object sender, EventArgs e) { KittingCodeDef item = new KittingCodeDef(); item.Code = this.dCode.Text.Trim(); item.Type = this.cmbKittingCodeType.InnerDropDownList.SelectedValue; item.Remark = this.dRemark.Text.Trim(); item.Descr = this.dDescr.Text.Trim(); item.Editor = this.HiddenUserName.Value; try { iKittingCodeMaintain.AddKittingCode(item); } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } ShowListByType(); String itemId = replaceSpecialChart(item.Code); this.updatePanel2.Update(); ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "AddUpdateComplete('" + itemId + "');DealHideWait();", true); }