Beispiel #1
0
 /// <summary>
 /// Create default columns for Master Data Version Table
 /// e.g. Processed, Processing, IsApproved etc.
 /// </summary>
 /// <param name="Ver_AD_Table_ID"></param>
 /// <returns></returns>
 private string CreateDefaultVerCols(int Ver_AD_Table_ID)
 {
     for (int i = 0; i < listDefVerCols.Count; i++)
     {
         MColumn colVer = new MColumn(GetCtx(), 0, _trx);
         colVer.SetExport_ID(null);
         colVer.SetAD_Table_ID(Ver_AD_Table_ID);
         colVer.SetColumnName(listDefVerCols[i]);
         colVer.SetAD_Element_ID(_listDefVerElements[i]);
         colVer.SetAD_Reference_ID(listDefVerRef[i]);
         //if (listDefVerCols[i] == "VersionValidFrom")
         //    colVer.SetIsParent(true);
         if (listDefVerRef[i] == 10)
         {
             colVer.SetFieldLength(10);
         }
         if (listDefVerRef[i] == 14)
         {
             colVer.SetFieldLength(2000);
         }
         if (listDefVerRef[i] == 13)
         {
             colVer.SetIsKey(true);
             colVer.SetIsMandatory(true);
             colVer.SetIsMandatoryUI(true);
         }
         if (!colVer.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 Version Column " + listDefVerCols[i];
             }
             log.Log(Level.SEVERE, "Version Column not created :: " + listDefVerCols[i] + " :: " + error);
             _trx.Rollback();
             return(Msg.GetMsg(GetCtx(), "VersionColNotCreated"));
         }
     }
     return("");
 }
Beispiel #2
0
        /// <summary>
        /// Create default columns for Master Data Version Table
        /// e.g. Processed, Processing, IsApproved etc.
        /// </summary>
        /// <param name="Ver_AD_Table_ID"></param>
        /// <returns></returns>
        private string CreateDefaultVerCols(int Ver_AD_Table_ID)
        {
            DataSet dstblCols = DB.ExecuteDataset("SELECT ColumnName FROM AD_Column WHERE AD_Table_ID = " + Ver_AD_Table_ID, null, null);

            for (int i = 0; i < listDefVerCols.Count; i++)
            {
                bool hasCol = false;
                if (dstblCols != null && dstblCols.Tables[0].Rows.Count > 0)
                {
                    DataRow[] dr = dstblCols.Tables[0].Select("ColumnName = '" + listDefVerCols[i] + "'");
                    if (dr != null && dr.Length > 0)
                    {
                        hasCol = true;
                    }
                }
                if (hasCol)
                {
                    continue;
                }
                MColumn colVer = new MColumn(GetCtx(), 0, _trx);
                colVer.SetExport_ID(null);
                colVer.SetAD_Table_ID(Ver_AD_Table_ID);
                colVer.SetColumnName(listDefVerCols[i]);
                colVer.SetAD_Element_ID(_listDefVerElements[i]);
                colVer.SetAD_Reference_ID(listDefVerRef[i]);
                //if (listDefVerCols[i] == "VersionValidFrom")
                //    colVer.SetIsParent(true);
                if (listDefVerRef[i] == 10)
                {
                    colVer.SetFieldLength(10);
                }
                if (listDefVerRef[i] == 14)
                {
                    colVer.SetFieldLength(2000);
                }
                if (listDefVerRef[i] == 13)
                {
                    colVer.SetIsKey(true);
                    colVer.SetIsMandatory(true);
                    colVer.SetIsMandatoryUI(true);
                }
                if (!colVer.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 Version Column " + listDefVerCols[i];
                    }
                    log.Log(Level.SEVERE, "Version Column not created :: " + listDefVerCols[i] + " :: " + error);
                    _trx.Rollback();
                    return(Msg.GetMsg(GetCtx(), "VersionColNotCreated"));
                }
                else
                {
                    oldVerCol = colVer.GetAD_Column_ID();
                }
            }
            return("");
        }