public void DeleteOneAcAdaptor(ACAdaptor item) { try { //调用repository 删除接口 ... //foreach (ACAdaptor acinfo in adaptorLst) //{ // if (acinfo.Assemb==item.Assemb) // { // adaptorLst.Remove(acinfo); // break; // } //} itemRepository.DeleteSelectedACAdaptor(item.id); } catch (FisException fex) { logger.Error(fex.Message); throw fex; } catch (System.Exception e) { logger.Error(e.Message); throw; } }
public string AddOneAcAdaptor(ACAdaptor item) { string id = ""; try { FisException ex = null; //调用repository 添加接口 ... // foreach(ACAdaptor ar in adaptorLst) // { // if (ar.assemb == item.assemb) // { // List<string> param=new List<string>(); // ex=new FisException("DMT063",param); // throw ex; // } // } //// if (ex==null) // { // adaptorLst.Add(item); // } IList<ACAdaptor> gradeLst = (IList<ACAdaptor>)GetAllAdaptorInfo(); foreach(ACAdaptor aa in gradeLst) { if(aa.assemb==item.assemb) { List<string> param = new List<string>(); ex = new FisException("DMT063", param); throw ex; } } item.cdt = DateTime.Now; itemRepository.AddOneAcAdaptor(item); id = item.id.ToString(); } catch (FisException fex) { logger.Error(fex.Message); throw; } catch (System.Exception e) { logger.Error(e.Message); throw; } //catch (Exception e) //{ // logger.Error(e.Message); // throw e; //} return id; }
public void UpdateOneAcAdaptorDefered(IUnitOfWork uow, ACAdaptor newItem) { InvokeBody.AddOneInvokeBody(this, uow, MethodBase.GetCurrentMethod(), newItem); }
public void UpdateOneAcAdaptor(ACAdaptor newItem) { try { FisException ex = null; Boolean duplicateFlag = false, notExistFlag = true; IList<ACAdaptor> gradeLst = (IList<ACAdaptor>)GetAllAdaptorInfo(); foreach (ACAdaptor aa in gradeLst) { if (aa.id == newItem.id) { notExistFlag = false; } if (aa.id != newItem.id&&aa.assemb.Trim().ToLower()==newItem.assemb.Trim().ToLower()) { duplicateFlag = true; } } if (notExistFlag) { List<string> param = new List<string>(); ex = new FisException("DMT083", param); throw ex; } else if (duplicateFlag) { List<string> param = new List<string>(); ex = new FisException("DMT063", param); throw ex; } newItem.udt = DateTime.Now; // newItem.cdt = oldACAdaptor.cdt; itemRepository.UpdateOneAcAdaptor(newItem); // if (newItem.Assemb == oldAssembly) //{ // //调用repository 更新接口 ... // ACAdaptor item = new ACAdaptor(); // foreach (ACAdaptor adaptor in adaptorLst) // { // if (adaptor.Assemb == oldAssembly) // { // item = adaptor; // adaptorLst.Remove(adaptor); // break; // } // } // item.Assemb = newItem.Assemb; // item.Adppn = newItem.Adppn; // item.Agency = newItem.Agency; // item.Supplier = newItem.Supplier; // item.Voltage = newItem.Voltage; // item.Cur = newItem.Cur; // item.Editor = newItem.Editor; // item.Udt = DateTime.Now.ToString(); // adaptorLst.Add(item); //} // else { //outOfWork begin //调用repository的add方法添加newItem //调用repository的删除方法将oldassembly删除. //outOfWork commit // AddOneAcAdaptor(newItem); // ACAdaptor ac = new ACAdaptor(); // ac.Assemb = oldAssembly; // DeleteOneAcAdaptor(ac); } } catch (FisException fex) { logger.Error(fex.Message); throw fex; } catch (System.Exception e) { logger.Error(e.Message); throw; } }
public void UpdateOneAcAdaptor(ACAdaptor newItem) { try { MethodBase mthObj = MethodBase.GetCurrentMethod(); int tk = mthObj.MetadataToken; SQLContextNew sqlCtx = null; lock (mthObj) { if (!SQLCache.PeerTheSQL(tk, out sqlCtx)) { AcAdapMaintain cond = new AcAdapMaintain(); cond.id = newItem.id; AcAdapMaintain setv = FuncNew.SetColumnFromField<AcAdapMaintain, ACAdaptor>(newItem, AcAdapMaintain.fn_id); setv.udt = DateTime.Now; sqlCtx = FuncNew.GetConditionedUpdate<AcAdapMaintain>(tk, new SetValueCollection<AcAdapMaintain>(new CommonSetValue<AcAdapMaintain>(setv)), new ConditionCollection<AcAdapMaintain>(new EqualCondition<AcAdapMaintain>(cond))); } } sqlCtx.Param(AcAdapMaintain.fn_id).Value = newItem.id; sqlCtx = FuncNew.SetColumnFromField<AcAdapMaintain, ACAdaptor>(sqlCtx, newItem, true); DateTime cmDt = _Schema.SqlHelper.GetDateTime(); sqlCtx.Param(g.DecSV(AcAdapMaintain.fn_udt)).Value = cmDt; _Schema.SqlHelper.ExecuteNonQuery(_Schema.SqlHelper.ConnectionString_BOM, CommandType.Text, sqlCtx.Sentence, sqlCtx.Params); } catch (Exception) { throw; } }
public void AddOneAcAdaptor(ACAdaptor item) { try { MethodBase mthObj = MethodBase.GetCurrentMethod(); int tk = mthObj.MetadataToken; SQLContextNew sqlCtx = null; lock (mthObj) { if (!SQLCache.PeerTheSQL(tk, out sqlCtx)) { sqlCtx = FuncNew.GetAquireIdInsert<AcAdapMaintain>(tk); } } DateTime cmDt = _Schema.SqlHelper.GetDateTime(); sqlCtx = FuncNew.SetColumnFromField<AcAdapMaintain, ACAdaptor>(sqlCtx, item); sqlCtx.Param(AcAdapMaintain.fn_cdt).Value = cmDt; sqlCtx.Param(AcAdapMaintain.fn_udt).Value = cmDt; item.id = _Schema.SqlHelper.ExecuteScalarForAquireIdInsert(_Schema.SqlHelper.ConnectionString_BOM, CommandType.Text, sqlCtx.Sentence, sqlCtx.Params); } catch (Exception) { throw; } }
protected void btnDelete_ServerClick(object sender, EventArgs e) { string oldAssembly = this.dOldAssemblyId.Value.Trim(); try { ACAdaptor adaptor = new ACAdaptor(); adaptor.id = Convert.ToInt32(this.dOldId.Value.Trim()); //调用删除方法. iACAdaptor.DeleteOneAcAdaptor(adaptor); } catch(FisException fex) { showErrorMessage(fex.mErrmsg); return; } catch(System.Exception ex) { showErrorMessage(ex.Message); return; } //按照ac adaptor list加载表格中的数据. //... showListByACAdaptorList(); this.updatePanel2.Update(); ScriptManager.RegisterStartupScript(this.updatePanel, typeof(System.Object), "saveUpdate", "resetTableHeight();DeleteComplete();HideWait();", true); }
protected void btnSave_ServerClick(object sender, EventArgs e) { ACAdaptor adaptor = new ACAdaptor(); string assembly = this.ttAssembly.Text.ToUpper().Trim(); // string oldassembly = this.dOldAssemblyId.Value.Trim(); // string oldCdt = this.dOldAssemblyCdt.Value.Trim(); //ACAdaptor oldAC = new ACAdaptor(); //oldAC.assemb = oldassembly; //oldAC.cdt = Convert.ToDateTime(oldCdt); adaptor.assemb = assembly; adaptor.adppn = this.ttadppn.Text.Trim(); adaptor.agency = this.ttAgency.Text.ToUpper().Trim(); adaptor.supplier = this.ttSupplier.Text.Trim(); adaptor.voltage = this.ttVoltage.Text.Trim(); adaptor.cur = this.ttCurrent.Text.Trim(); adaptor.editor = this.HiddenUserName.Value.Trim(); adaptor.id = Convert.ToInt32(this.dOldId.Value.Trim()); string id = this.dOldId.Value.Trim(); try { //调用更新方法1... 相同key时需要抛出异常... iACAdaptor.UpdateOneAcAdaptor(adaptor); } catch(FisException fex) { showErrorMessage(fex.mErrmsg); return; } catch(System.Exception ex) { //IList<IMES.DataModel.ACAdaptor> datalst = iACAdaptor.GetAllAdaptorInfo(); //bindTable(datalst, DEFAULT_ROWS); showErrorMessage(ex.Message); return; } //根据ac acdaptor list的数据加载表格中的数据 //... showListByACAdaptorList(); this.updatePanel2.Update(); // string currentAssmebly = replaceSpecialChart(assembly); ScriptManager.RegisterStartupScript(this.updatePanel, typeof(System.Object), "saveUpdate", "resetTableHeight();AddUpdateComplete('" + id + "');HideWait();", true); }
protected void btnAdd_ServerClick(object sender, EventArgs e) { ACAdaptor adaptor = new ACAdaptor(); adaptor.assemb = this.ttAssembly.Text.ToUpper().Trim();//需要转化为upperCase... adaptor.adppn = this.ttadppn.Text.Trim(); adaptor.agency = this.ttAgency.Text.ToUpper().Trim();//需要转化为UpperCase... adaptor.supplier = this.ttSupplier.Text.Trim(); adaptor.voltage = this.ttVoltage.Text.Trim(); adaptor.cur = this.ttCurrent.Text.Trim(); adaptor.editor = this.HiddenUserName.Value; System.DateTime cdt = DateTime.Now;; string timeStr = cdt.ToString(); adaptor.cdt = cdt; string id = ""; try { //调用添加的方法 相同的key时需要抛出异常... id=iACAdaptor.AddOneAcAdaptor(adaptor); } catch(FisException fex) { showErrorMessage(fex.mErrmsg); return; } catch(System.Exception ex) { showErrorMessage(ex.Message); return; } //按照ac adaptor list加载表格中的数据 //... showListByACAdaptorList(); this.updatePanel2.Update(); // string assemblyId = replaceSpecialChart(adaptor.assemb); ScriptManager.RegisterStartupScript(this.updatePanel, typeof(System.Object), "saveUpdate", "resetTableHeight();AddUpdateComplete('" + id + "');HideWait();", true); }