Exemplo n.º 1
0
    public bool Load(CCommand Command, string FileName, string BranchCode, string TaskCode)
    {
        int    LineNum;
        bool   Result = true;
        string DebitAcc, CreditAcc, DebitIBAN, CreditIBAN;

        if (AFileReader == null)
        {
            return(false);
        }
        if (AFileReader.Open(FileName, CAbc.CHARSET_DOS))
        {
            string ShortFileName = CCommon.GetFileName(FileName);
            LineNum = 1;
            while (AFileReader.Read())
            {
                DebitAcc   = AFileReader[CSepAFileInfo.L_DEBITACC].Replace("'", "`").Trim();
                DebitAcc   = CCommon.IsDigit(DebitAcc) ? DebitAcc : AFileReader[CSepAFileInfo.L_DEBITACC_EXT].Replace("'", "`").Trim();
                DebitAcc   = CCommon.IsDigit(DebitAcc) ? DebitAcc : "";
                CreditAcc  = AFileReader[CSepAFileInfo.L_CREDITACC].Replace("'", "`").Trim();
                CreditAcc  = CCommon.IsDigit(CreditAcc) ? CreditAcc : AFileReader[CSepAFileInfo.L_CREDITACC_EXT].Replace("'", "`").Trim();
                CreditAcc  = CCommon.IsDigit(CreditAcc) ? CreditAcc : "";
                DebitIBAN  = AFileReader[CSepAFileInfo.L_DEBITIBAN].Replace("'", "`").Trim();
                DebitIBAN  = CCommon.IsLetter(DebitIBAN) ? DebitIBAN : CAbc.EMPTY;
                CreditIBAN = AFileReader[CSepAFileInfo.L_CREDITIBAN].Replace("'", "`").Trim();
                CreditIBAN = CCommon.IsLetter(CreditIBAN) ? CreditIBAN : CAbc.EMPTY;
                CmdText    = "exec  dbo.pMega_OpenGate_AddPalvis "
                             + " @TaskCode     = '" + TaskCode.Trim() + "'"
                             + ",@BranchCode   = '" + BranchCode.Trim() + "'"
                             + ",@FileName     = '" + ShortFileName + "'"
                             + ",@LineNum      =  " + LineNum.ToString()
                             + ",@Code         = '" + AFileReader[CSepAFileInfo.L_NDOC].Replace("'", "`").Trim() + "'"
                             + ",@Ctrls        = '" + AFileReader[CSepAFileInfo.L_SYMBOL].Replace("'", "`").Trim() + "'"
                             + ",@SourceCode   = '" + AFileReader[CSepAFileInfo.L_DEBITMFO].Replace("'", "`").Trim() + "'"
                             + ",@DebitMoniker = '" + DebitAcc + "'"
                             + ",@DebitName    = '" + AFileReader[CSepAFileInfo.L_DEBITNAME].Replace("'", "`").Trim() + "'"
                             + ",@DebitState   = '" + AFileReader[CSepAFileInfo.L_OKPO1].Replace("'", "`").Trim() + "'"
                             + ",@DebitIBAN    = '" + DebitIBAN + "'"
                             + ",@TargetCode   = '" + AFileReader[CSepAFileInfo.L_CREDITMFO].Replace("'", "`").Trim() + "'"
                             + ",@CreditMoniker= '" + CreditAcc + "'"
                             + ",@CreditName   = '" + AFileReader[CSepAFileInfo.L_CREDITNAME].Replace("'", "`").Trim() + "'"
                             + ",@CreditState  = '" + AFileReader[CSepAFileInfo.L_OKPO2].Replace("'", "`").Trim() + "'"
                             + ",@CreditIBAN   = '" + CreditIBAN + "'"
                             + ",@CrncyAmount  =  " + AFileReader[CSepAFileInfo.L_SUMA].Replace("'", "`").Trim()
                             + ",@CurrencyId   =  " + AFileReader[CSepAFileInfo.L_CURRENCY].Replace("'", "`").Trim()
                             + ",@Purpose      = '" + AFileReader[CSepAFileInfo.L_PURPOSE].Replace("'", "`").Trim() + "'"
                             + ",@OrgDate      =  " + CCommon.StrDate_To_IntDate("20" + AFileReader[CSepAFileInfo.L_DATE2].Trim())
                             + ",@UserName		= '******'"
                ;
                if (Command.Execute(CmdText) != true)
                {
                    Result = false;
                }
                LineNum = LineNum + 1;
                CConsole.ShowBox("", " Загружается строка" + CCommon.StrI(LineNum, 5) + " ", "");
            }
        }
        AFileReader.Close();
        return(Result);
    }
Exemplo n.º 2
0
 public bool Add(params string[] MetaData)
 {
     if (HFile == null)
     {
         return(false);
     }
     if (MetaData == null)
     {
         return(true);
     }
     if (!HasHeaderWritten)
     {
         base.Add(HEADER);
         base.Add(CAbc.CRLF);
         HasHeaderWritten = true;
     }
     for (int CurrentField = 0; CurrentField < MetaData.Length; CurrentField++)
     {
         if (MetaData[CurrentField] == CAbc.CRLF)
         {
             FieldCounter = 1;
             LineCounter++;
             return(base.Add(CAbc.CRLF));
         }
         else
         if (CCommon.IsDigit(MetaData[CurrentField]))
         {
             if (!base.Add("C;X"
                           , (FieldCounter++).ToString()
                           , ";Y"
                           , LineCounter.ToString()
                           , ";K"
                           , MetaData[CurrentField].Replace(",", ".")
                           , CAbc.CRLF
                           )
                 )
             {
                 return(false);
             }
         }
         else
         {
             if (!base.Add("C;X"
                           , (FieldCounter++).ToString()
                           , ";Y"
                           , LineCounter.ToString()
                           , ";K"
                           , CAbc.QUOTE
                           , MetaData[CurrentField].Replace(";", ";;")
                           , CAbc.QUOTE
                           , CAbc.CRLF
                           )
                 )
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 3
0
    public bool    Load()
    {
        if (Connection == null)
        {
            return(false);
        }
        CRecordSet RecordSet = new   CRecordSet(Connection);

        if (RecordSet.Open("declare @OwnerCode as VarChar(32) select @OwnerCode=user_name() exec dbo.Mega_Common_Registry;1 @OwnerCode=@OwnerCode , @TaskCode='loader' , @TaskName='TAL\\FILIAL\\LOADER.EXC' "))
        {
            while (RecordSet.Read())
            {
                if (CCommon.IsDigit("0" + RecordSet["FlagCode"].Trim()))
                {
                    Current = CCommon.CInt32("0" + RecordSet["FlagCode"].Trim());
                    if (Current < TOTAL_GROUP)
                    {
                        Topics[Current]   = RecordSet["Name"].Trim();
                        Purposes[Current] = RecordSet["Info"].Trim();
                    }
                }
            }
        }
        RecordSet.Close();
        Print();
        Current = CConsole.GetMenuChoice("Принять такие назначения платежей", "Изменить назначения платежей");
        while (Current == 2)
        {
            Print();
            Current = CConsole.GetMenuChoice(TopicMenus);
            while (Current != 0)
            {
                CCommon.Write(" Введите номер балансового счета или список через запятую : ");
                Topics[Current - 1] = CCommon.Input().Trim();
                CCommon.Write(CAbc.CRLF + " Назначение платежа : ");
                Purposes[Current - 1] = CCommon.Input().Trim();
                Print();
                Current = CConsole.GetMenuChoice(TopicMenus);
            }
            Print();
            Current = CConsole.GetMenuChoice("Принять такие назначения платежей", "Изменить назначения платежей");
        }
        if (Current == 1)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 4
0
 public bool Add(params string[] MetaData)
 {
     if (MetaData == null)
     {
         return(true);
     }
     if (HeaderStatus == 0)
     {
         base.Add(HEADER);
         HeaderStatus = 1;
     }
     if (HeaderStatus == 1)
     {
         base.Add(BOT);
         HeaderStatus = 2;
     }
     for (int CurrentField = 0; CurrentField < MetaData.Length; CurrentField++)
     {
         CurrentStr  = MetaData[CurrentField].Replace(CAbc.QUOTE, CAbc.QUOTE + CAbc.QUOTE);
         CurrentStr2 = CurrentStr.Replace(",", "0");
         if (CurrentStr == CAbc.CRLF)
         {
             HeaderStatus = 1;
             if (!base.Add(CAbc.CRLF))
             {
                 return(false);
             }
         }
         if (CCommon.IsDigit(CurrentStr2))
         {
             if (!base.Add("0,", CurrentStr, CAbc.CRLF, "V", CAbc.CRLF))
             {
                 return(false);
             }
         }
         else
         if (!base.Add("1,0", CAbc.CRLF, CAbc.QUOTE, CurrentStr, CAbc.QUOTE, CAbc.CRLF))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 5
0
    public string  Check(CCommand Command, string SourceFileName)
    {
        string Result        = "";
        string AboutError    = "";
        bool   HaveError     = false;
        string ShortFileName = CCommon.GetFileName(SourceFileName);

        TotalCredit = 0;
        StringCount = 0;
        if (AFileReader.Open(SourceFileName, CAbc.CHARSET_DOS))
        {
            HaveError = false;
            while (AFileReader.Read())
            {
                TotalCredit += CCommon.CInt64(AFileReader[CSepAFileInfo.L_SUMA].Trim());
                StringCount++;
                AboutError = "";
                CmdText    = "exec   dbo.pMega_OpenGate_CheckPalvis"
                             + " @Code         = '" + AFileReader[CSepAFileInfo.L_NDOC].Replace("'", "`").Trim() + "'"
                             + ",@Ctrls        = '" + AFileReader[CSepAFileInfo.L_NDOC].Replace("'", "`").Trim() + "'"
                             + ",@SourceCode   = '" + AFileReader[CSepAFileInfo.L_DEBITMFO].Replace("'", "`").Trim() + "'"
                             + ",@DebitMoniker = '" + AFileReader[CSepAFileInfo.L_DEBITACC].Replace("'", "`").Trim() + "'"
                             + ",@DebitState   = '" + AFileReader[CSepAFileInfo.L_OKPO1].Replace("'", "`").Trim() + "'"
                             + ",@DebitIBAN    = '" + AFileReader[CSepAFileInfo.L_DEBITIBAN].Replace("'", "`").Trim() + "'"
                             + ",@TargetCode   = '" + AFileReader[CSepAFileInfo.L_CREDITMFO].Replace("'", "`").Trim() + "'"
                             + ",@CreditMoniker= '" + AFileReader[CSepAFileInfo.L_CREDITACC].Replace("'", "`").Trim() + "'"
                             + ",@CreditState  = '" + AFileReader[CSepAFileInfo.L_OKPO2].Replace("'", "`").Trim() + "'"
                             + ",@CreditIBAN   = '" + AFileReader[CSepAFileInfo.L_CREDITIBAN].Replace("'", "`").Trim() + "'"
                             + ",@CrncyAmount  =  " + AFileReader[CSepAFileInfo.L_SUMA].Replace("'", "`").Trim()
                             + ",@CurrencyId   =  " + AFileReader[CSepAFileInfo.L_CURRENCY].Replace("'", "`").Trim()
                             + ",@FileName     = '" + ShortFileName.Replace("'", "`").Trim() + "'"
                             + ",@LineNum      =  " + StringCount.ToString()
                             + ",@UserName	= '******'"
                ;
                AboutError = (string)Command.GetScalar(CmdText);
                if (AFileReader[CSepAFileInfo.L_PURPOSE].Trim() == "")
                {
                    AboutError += " Не заполнено назначение платежа ;";
                }
                if (AFileReader[CSepAFileInfo.L_DEBITNAME].Trim() == "")
                {
                    AboutError += " Не заполнено название дб. счета ;";
                }
                if (AFileReader[CSepAFileInfo.L_CREDITNAME].Trim() == "")
                {
                    AboutError += " Не заполнено название кт. счета ;";
                }
                if (AboutError != null)
                {
                    if ((AboutError.Trim() != ""))
                    {
                        HaveError = true;
                        Result    = Result + " Ошибка в строке " + StringCount.ToString() + " : " + AboutError.Trim() + CAbc.CRLF;
                    }
                }
                CConsole.ShowBox("", " Проверяется строка" + CCommon.StrI(StringCount, 5) + " ", "");
            }
            CConsole.Clear();
            if (HaveError)
            {
                Result = Result + "Ошибка в реквизитах платежей !" + CAbc.CRLF;
            }
            if (TotalCredit != CCommon.CInt64(AFileReader.Head(CSepAFileInfo.H_TOTALCREDIT).Trim()))
            {
                Result = Result + CAbc.CRLF + "Неверная итоговая сумма платежей !" + CAbc.CRLF;
            }
            if (CCommon.IsDigit("0" + AFileReader.Head(CSepAFileInfo.H_STRCOUNT).Trim()) == false)
            {
                Result = Result + CAbc.CRLF + "Неверное общее количество строк !" + CAbc.CRLF;
            }
            else
            if (StringCount != CCommon.CInt32("0" + AFileReader.Head(CSepAFileInfo.H_STRCOUNT).Trim()))
            {
                Result = Result + CAbc.CRLF + "Неверное общее количество строк !" + CAbc.CRLF;
            }
        }
        else
        {
            Result += "Ошибка чтения файла !" + CAbc.CRLF;
        }
        AFileReader.Close();
        byte SavedColor = CConsole.BoxColor;

        if ((( int )CCommon.IsNull(Command.GetScalar("exec dbo.pMega_OpenGate_CheckPalvis;2 @TaskCode='OpenGate',@FileName='" + ShortFileName + "'"), (int)0)) > 0)
        {
            CConsole.BoxColor = CConsole.RED * 16 + CConsole.WHITE;
            CConsole.GetBoxChoice("Внимание ! Файл " + ShortFileName + " сегодня уже загружался !", "", "Нажмите Enter.");
            HaveError         = true;
            Result           += "Файл " + ShortFileName + " сегодня уже загружался !" + CAbc.CRLF;
            CConsole.BoxColor = SavedColor;
        }
        return(Result);
    }