Example #1
0
 public ParseErrorDialog(SourceText srcTxt, Object MainWnd, string message, string caption)
 {
     m_lbl_Message = message;
     m_caption = caption;
     m_SourceText = srcTxt;
     m_MainWindow = MainWnd;
     InitializeComponent();
 }
Example #2
0
 private void GetValue_FromSourceText(SourceText sTxt, string s2, ref string Value)
 {
     string[] token = s2.Split('=');
     char[] SkipSpaces = { ' ', '\t' };
     if (token.Length >= 2)
     {
         string sCommand = token[0];
         sCommand.TrimStart(SkipSpaces);
         sCommand.TrimEnd(SkipSpaces);
         if (sCommand.Equals(ASet.KEYWORD_LINES))
         {
             string sNumOfLines = token[1];
             sNumOfLines.TrimStart(SkipSpaces);
             sNumOfLines.TrimEnd(SkipSpaces);
             int NumOfLines = Convert.ToInt32(sNumOfLines);
             int i;
             for (i = 0; i < NumOfLines; i++)
             {
                 sTxt.ReadLine();
                 Value += sTxt.sLine;
             }
         }
         else
         {
             Value = s2;
         }
     }
     else
     {
         Value = s2;
     }
 }
Example #3
0
        public bool SQLcmd_ImportFile(Form mMainForm, string FileName, ref List<SQLTable> lTable)
        {
            List<SQL_Parameter> lsqlPar = new List<SQL_Parameter>();

            SQLTable sqlTbl = null;
            SQLTable refsqlTbl = null;
            int iTableNameStart;
            int iTableNameEnd;
            Globals.MainWindow = mMainForm;
            StringBuilder sbSQLInsert = new StringBuilder(m_strSQLUseDatabase.ToString());
            string sPrevVar = "";
            SourceText Source_Txt = new SourceText(FileName);

            char[] trimChars = new char[] { ' ', '\t' };
            if (Source_Txt.OpenText())
            {
                while (Source_Txt.ReadLine())
                {
                    if (sqlTbl != null)
                    {
                        iTableNameStart = Source_Txt.sLine.IndexOf('<');
                        if (iTableNameStart != -1)
                        {
                            iTableNameStart++;
                            if (Source_Txt.sLine[iTableNameStart].Equals('/'))
                            {
                                iTableNameStart++;
                                iTableNameEnd = Source_Txt.sLine.IndexOf('>');
                                string sTblName = Source_Txt.sLine.Substring(iTableNameStart, iTableNameEnd - iTableNameStart);
                                if (sqlTbl.TableName.Equals(sTblName))
                                {
                                    string sVarID = Globals.sVar + "_" + sqlTbl.TableName;
                                    sPrevVar = Globals.sVar;
                                    string ErrorMsg = "";
                                    Int64 newID = -1;
                                    if (sqlTbl.SQLcmd_InsertInto(m_con,lTable, ref ErrorMsg, m_strSQLUseDatabase, ref newID))
                                    {
                                        sqlTbl = null;
                                    }
                                    else
                                    {
                                        return false;
                                    }
                                }
                                else
                                {
                                    Source_Txt.ShowParseError(lngRPM.s_Illegal_end_table_XML_command_expected.s + ": </" + sqlTbl.TableName + ">\n", lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                    Source_Txt.CloseText();
                                }
                            }
                            else
                            {
                                Source_Txt.ShowParseError(lngRPM.s_Illegal_end_table_XML_command_expected.s + ": </" + sqlTbl.TableName + ">\n", lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                Source_Txt.CloseText();
                            }
                        }
                        else
                        {
                            string[] column = Source_Txt.sLine.Split(',');
                            int iCount = column.Length;
                            string s1;
                            string s2 = "";
                            if (iCount >= 2)
                            {
                                s1 = column[0];
                                int i;
                                for (i = 1; i < iCount; i++)
                                {
                                    s2 += column[i];
                                }
                                string Value = "";
                                GetValue_FromSourceText(Source_Txt, s2, ref Value);
                                if (sqlTbl.SetColumnValue(s1, Value))
                                {
                                    continue;
                                }
                                else
                                {
                                    Source_Txt.CloseText();
                                    return false;
                                }
                            }
                            else
                            {
                                Source_Txt.ShowParseError(lngRPM.s_File.s + ":" + FileName + "\n" + lngRPM.s_Comma_is_missing_to_separate_cells_column_name_from_cell_value_in_line.s + ":" + Source_Txt.iLine.ToString(), lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                Source_Txt.CloseText();
                                return false;
                            }
                        }
                    }
                    else
                    {
                        iTableNameStart = Source_Txt.sLine.IndexOf('<');
                        iTableNameEnd = Source_Txt.sLine.IndexOf('>');
                        if ((iTableNameStart != -1) && (iTableNameEnd != -1) && (iTableNameEnd > iTableNameStart))
                        {
                            string sTableName = Source_Txt.sLine.Substring(iTableNameStart + 1, iTableNameEnd - iTableNameStart - 1);
                            sTableName = sTableName.TrimStart(trimChars);
                            sTableName = sTableName.TrimEnd(trimChars);
                            if (Globals.FindTable(out refsqlTbl, sTableName, items))
                            {
                                sqlTbl = new SQLTable(refsqlTbl);
                                sqlTbl.CreateTableTree(lTable);
                                continue;
                            }
                            else
                            {
                                Source_Txt.ShowParseError(lngRPM.s_TableNameIsExpectedToBeBeforeDataLines.s, lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                return false;
                            }

                        }
                        else
                        {
                            Source_Txt.ShowParseError(lngRPM.s_TableNameIsExpectedToBeBeforeDataLines.s, lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            return false;
                        }
                    }
                }
                Source_Txt.CloseText();

                //  Structures are filled now create SQL statements

                return true;

            }
            else
            {
                return false;
            }
        }
Example #4
0
 public bool SetObjValue(string Value, SourceText sTxt)
 {
     string sAction = "";
     //string Value = Globals.RemoveComas(Val);
     //string Value = Val;
     Type type = this.BasicType();
     string csError = null;
     if (DBTypes.DBtypesFunc.SetObjValue(ref this.obj, type, ref sAction, Value, ref csError))
     {
         return true;
     }
     else
     {
         sTxt.ShowParseError(csError, lngRPM.s_Error.s, MessageBoxButtons.OK, MessageBoxIcon.Error);
         return false;
     }
 }