/// <summary> /// /// </summary> /// <param name="VerTblName"></param> public void GetSystemElements(string VerTblName) { if (_listDefVerElements.Count == listDefVerCols.Count) { return; } _listDefVerElements.Clear(); if (!listDefVerCols.Contains(VerTblName + "_ID")) { listDefVerCols.Add(VerTblName + "_ID"); } string DefSysEle = string.Join(",", listDefVerCols .Select(x => string.Format("'{0}'", x))); DataSet dsDefVerCols = DB.ExecuteDataset("SELECT AD_Element_ID, ColumnName FROM AD_Element WHERE ColumnName IN (" + DefSysEle + ")", null, Get_TrxName()); if (dsDefVerCols != null && dsDefVerCols.Tables[0].Rows.Count > 0) { for (int i = 0; i < listDefVerCols.Count; i++) { DataRow[] drSysEle = dsDefVerCols.Tables[0].Select("ColumnName='" + listDefVerCols[i] + "'"); if (drSysEle.Length > 0) { if (!_listDefVerElements.Contains(Util.GetValueOfInt(drSysEle[0]["AD_Element_ID"]))) { _listDefVerElements.Add(Util.GetValueOfInt(drSysEle[0]["AD_Element_ID"])); } } else { M_Element ele = new M_Element(GetCtx(), 0, Get_Trx()); ele.SetAD_Client_ID(0); ele.SetAD_Org_ID(0); ele.SetName(listDefVerCols[i]); ele.SetColumnName(listDefVerCols[i]); ele.SetPrintName(listDefVerCols[i]); if (!ele.Save()) { } else { _listDefVerElements.Add(ele.GetAD_Element_ID()); if (ele.GetColumnName() == VerTblName + "_ID") { listDefVerRef.Add(13); } } } } } }
/// <summary> /// Get System Elements for Default Columns /// </summary> /// <param name="VerTblName">Table Name</param> public string GetSystemElements(string VerTblName) { // check if count in list is equal to default version columns if (_listDefVerElements.Count == listDefVerCols.Count) { return(""); } // Clear values from list _listDefVerElements.Clear(); // check if Primary key column is present in Columns list, if not present then add Primary Key column if (!listDefVerCols.Contains(VerTblName + "_ID")) { listDefVerCols.Add(VerTblName + "_ID"); } // Create comma separated string of all default version columns string DefSysEle = string.Join(",", listDefVerCols .Select(x => string.Format("'{0}'", x))); // Get System Elements and Column Names for all Version table columns DataSet dsDefVerCols = DB.ExecuteDataset("SELECT AD_Element_ID, ColumnName FROM AD_Element WHERE ColumnName IN (" + DefSysEle + ")", null, _trx); if (dsDefVerCols != null && dsDefVerCols.Tables[0].Rows.Count > 0) { // loop through all columns of version table to get System Elements // if not found then create new for (int i = 0; i < listDefVerCols.Count; i++) { DataRow[] drSysEle = dsDefVerCols.Tables[0].Select("ColumnName='" + listDefVerCols[i] + "'"); if (drSysEle.Length > 0) { if (!_listDefVerElements.Contains(Util.GetValueOfInt(drSysEle[0]["AD_Element_ID"]))) { _listDefVerElements.Add(Util.GetValueOfInt(drSysEle[0]["AD_Element_ID"])); } if (listDefVerCols[i] == VerTblName + "_ID") { listDefVerRef.Add(13); } } else { M_Element ele = new M_Element(GetCtx(), 0, _trx); ele.SetAD_Client_ID(0); ele.SetAD_Org_ID(0); ele.SetName(listDefVerCols[i]); ele.SetColumnName(listDefVerCols[i]); ele.SetPrintName(listDefVerCols[i]); if (!ele.Save()) { ValueNamePair vnp = VLogger.RetrieveError(); string error = ""; if (vnp != null) { error = vnp.GetName(); if (error == "" && vnp.GetValue() != null) { error = vnp.GetValue(); } } if (error == "") { error = "Error in creating System Element"; } log.Log(Level.SEVERE, error); _trx.Rollback(); return(Msg.GetMsg(GetCtx(), "ElementNotSaved")); } else { _listDefVerElements.Add(ele.GetAD_Element_ID()); if (ele.GetColumnName() == VerTblName + "_ID") { listDefVerRef.Add(13); } } } } } return(""); }