/// <summary> /// 根據KEY批量刪除數據 /// </summary> /// <param name="p_strKey1"></param> /// <param name="p_strKey2"></param> /// <returns></returns> /// <remarks>(NO:0005078) 現時只用於刪除從Maximo系統同步過來的機台部件 Add By Leothlik TonyWu On 18/07/2014</remarks> public bool RemoveByKey(CustEnum.KEY1 key1) { bool isSuccess = false; try { using (MainDBDataContext db = new MainDBDataContext()) { string l_strKey1 = Enum.GetName(key1.GetType(), key1); var l_lisOldData = db.CodeMaster_cmt.Where(p => p.cmt_cKey1 == l_strKey1.Trim()).ToList(); if (l_lisOldData.Count > 0) { db.CodeMaster_cmt.DeleteAllOnSubmit(l_lisOldData); db.SubmitChanges(); isSuccess = true; } } } catch (Exception Ex) { throw Ex; } return isSuccess; }
/// <summary> /// 返回字碼主檔 /// add by justinleung /// </summary> /// <param name="system">系統名稱</param> /// <param name="key1">模塊1</param> /// <param name="key2">模塊2</param> /// <returns></returns> public IList<CodeMaster_cmt_Info> GetCodeMasters(CustEnum.System system, CustEnum.KEY1 key1, CustEnum.KEY2 key2) { IList<CodeMaster_cmt_Info> infos = null; if (CustEnum.System.HBManager == system) { try { this._codeMasterDA = SQLDAFactory.GetDAL<ICodeMasterDA>(SQLDAFactory.CodeMaster_cmt); //Dictionary<string, object> param = new Dictionary<string, object>(); //param.Add("cmt_cKey1", Enum.GetName(key1.GetType(), key1)); //param.Add("cmt_cKey2", Enum.GetName(key2.GetType(), key2)); CodeMaster_cmt_Info info = new CodeMaster_cmt_Info(); info.cmt_cKey1 = Enum.GetName(key1.GetType(), key1); info.cmt_cKey2 = Enum.GetName(key2.GetType(), key2); infos = this._codeMasterDA.SearchRecords(info); } catch { throw new Exception(Resource.B0002); } } //else if (CustEnum.System.PPC == system) //{ // try // { // this._codeMasterDA = SQLiteDAFacotry.CodeMasterDAInstance; // Dictionary<string, object> param = new Dictionary<string, object>(); // param.Add("cmt_cKey1", Enum.GetName(key1.GetType(), key1)); // param.Add("cmt_cKey2", Enum.GetName(key2.GetType(), key2)); // infos = this._codeMasterDA.GetEntities<CodeMaster_cmt_Info>(param).OrderBy(d=>d.cmt_cValue).ToList(); // } // catch (Exception ex) // { // throw new Exception(Resource.B0001 + ex.Message); // } //} return infos; }