Beispiel #1
0
 public string UpdateMemberParty()
 {
     con.sqlCommand("UpdateMemberParty");
     con.InsertValint("@member_code", MemberCode);
     con.InsertValstring("@party_name", PartyName.Trim());
     con.InsertValstring("@f_name", FName.Trim());
     con.InsertValstring("@l_name", LName.Trim());
     con.InsertValstring("@birth_date", GetDob().ToString());
     con.InsertValint("@list_place", ListPlace);
     con.InsertValstring("@education", Education.Trim());
     con.InsertValstring("@experience", Experience.Trim());
     return(con.getVal("@Result").ToString());
 }
Beispiel #2
0
        private void searchitem()
        {
            string     sql    = "select * from Ordertbl";
            string     name   = "";
            string     qtystr = "";
            SqlCommand cmd    = new SqlCommand(sql, cnn);

            cnn.Open(); SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                name = dr["Name"].ToString();
                if (name.Trim() == FName.Trim())
                {
                    qtystr = dr["Quantity"].ToString();
                    addqty = Convert.ToInt32(qtystr.Trim());
                }
            }
            cnn.Close();
        }
Beispiel #3
0
    public static void Main()
    {
        Err.LogToConsole();
        int          ErcDate          = 0;
        bool         UseErcRobot      = false;                                  // подключаться ли к серверу под логином ErcRobot
        string       FileName         = CAbc.EMPTY;
        const string ROBOT_LOGIN      = "******";
        const string ROBOT_PWD        = "35162987";
        const string TASK_CODE        = "OpenGate";
        string       StatDir          = null;
        string       DataBase         = null;
        string       ServerName       = null;
        string       ScroogeDir       = null;
        string       SettingsDir      = null;
        string       ConnectionString = null;

        if (System.Console.BufferHeight > 50)
        {
            System.Console.WindowHeight = 25;
            System.Console.BufferHeight = 25;
        }
        System.Console.Title           = "Загрузка в `Скрудж` платежей из А-файлов ";
        System.Console.BackgroundColor = 0;
        System.Console.Clear();
        CCommon.Print("", "  Загрузка в `Скрудж` платежей из А-файлов. Версия 3.03 от 29.08.2019г.");
        if (CCommon.ParamCount() < 2)
        {
            CCommon.Print("  В строке запуска нужно указатьть один из режимов :");
            CCommon.Print("  /A   диалоговый режим, для загрузки файлов для универсального шлюза ;");
            CCommon.Print("  /С   проверка одного файла, имя которого задано далее в строке ;");
            CCommon.Print("  /D   `браковка` заготовок из файла, имя которого задано далее в строке ;");
            CCommon.Print("  /S   пакетный режим  , для загрузки файлов от САКР ( маска !A??_*.* ) ;");
            CCommon.Print("  /U   диалоговый режим, для загрузки файлов от ЕРЦ  ( кроме !A??_*.* ) ;");
            CCommon.Print("  /Z   диалоговый режим, для загрузки файлов зарплаты( маска !A*.Z??  ) .");
            CCommon.Print("", "  /R   дополнительная опция - подключаться под пользователем ErcRobot .");
            return;
        }
        if (CCommon.ParamCount() == 0)
        {
            return;
        }
        for (int i = 1; i < CCommon.ParamCount(); i++)
        {
            if (CAbc.ParamStr[i].Trim().ToUpper() == "/R")
            {
                UseErcRobot          = true;
                System.Console.Title = System.Console.Title + " * ";
            }
            else
            if (CAbc.ParamStr[i].Trim().Substring(0, 1) == "/")
            {
                WorkMode = CCommon.Upper(CAbc.ParamStr[i]).Trim();
            }
            else
            {
                FileName = CAbc.ParamStr[i].Trim();
            }
        }
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // Вычитываем настройки "Скрудж-2"
        ErcAFile       = new   CErcAFile();
        ErcEFile       = new   CErcEFile();
        Scrooge2Config = new   CScrooge2Config();
        if (!Scrooge2Config.IsValid)
        {
            CCommon.Print(Scrooge2Config.ErrInfo);
            return;
        }
        ScroogeDir  = (string)Scrooge2Config["Root"];
        SettingsDir = (string)Scrooge2Config["Common"];
        ServerName  = (string)Scrooge2Config["Server"];
        DataBase    = (string)Scrooge2Config["DataBase"];
        if (ScroogeDir == null)
        {
            CCommon.Print("  Не найдена переменная `Root` в настройках `Скрудж-2` ");
            return;
        }
        if (ServerName == null)
        {
            CCommon.Print("  Не найдена переменная `Server` в настройках `Скрудж-2` ");
            return;
        }
        if (DataBase == null)
        {
            CCommon.Print("  Не найдена переменная `Database` в настройках `Скрудж-2` ");
            return;
        }
        ScroogeDir = ScroogeDir.Trim();
        if (SettingsDir != null)
        {
            SettingsDir = ScroogeDir + "\\" + SettingsDir;
        }
        ServerName = ServerName.Trim();
        DataBase   = DataBase.Trim();
        CCommon.Print("  Беру настройки `Скрудж-2` здесь :  " + ScroogeDir);
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // Подключаемся к базе данных
        ConnectionString = "Server=" + ServerName
                           + ";Database=" + DataBase;
        if (UseErcRobot)
        {
            ConnectionString += ";UID=" + ROBOT_LOGIN + ";PWD=" + ROBOT_PWD + ";";
        }
        else
        {
            ConnectionString += ";Integrated Security=TRUE;";
        }
        Connection = new   CConnection(ConnectionString);
        if (Connection.IsOpen())
        {
            /* CCommon.Print("  Сервер        :  " + ServerName ) */;
        }
        else
        {
            CCommon.Print("  Ошибка подключения к серверу !");
            return;
        }
        Command = new   CCommand(Connection);
        if (Command.IsOpen())
        {
            /* CCommon.Print("  База данных   :  " + DataBase ) */;
        }
        else
        {
            CCommon.Print("  Ошибка подключения к базе данных !");
            return;
        }
        System.Console.Title = System.Console.Title + " | " + ServerName + "." + DataBase;
        // - - - - - - - - - - - - - - - - -
        // считываем настройки шлюза в ЕРЦ
        AppSettings = new   CAppSettings(Connection);
        ErcDate     = ( int )CCommon.IsNull(Command.GetScalar(" exec  dbo.pMega_OpenGate_Days;7 "), (int)0);
        if (ErcDate < 1)
        {
            CCommon.Print(" Ошибка определения даты текущего рабочего дня. ");
            return;
        }
        switch (WorkMode)
        {
        case    WorkModes.CHECK:
        {
            SeanceNum = 1;
            ErcConfig = new   COpenwayConfig();
            ErcConfig.Open(ErcDate);
            InputDir = (string)ErcConfig["InputDir"];
            break;
        }

        case    WorkModes.DISABLE:
        {
            SeanceNum = 1;
            ErcConfig = new   COpenwayConfig();
            ErcConfig.Open(ErcDate);
            InputDir = (string)ErcConfig["InputDir"];
            break;
        }

        case    WorkModes.SALARY:
        {
            SeanceNum = ( int )CCommon.IsNull(Command.GetScalar(" exec dbo.pMega_OpenGate_Days;4  @TaskCode='ErcGate',@ParamCode='NumSeance' "), (int)0);
            ErcConfig = new   CSalaryConfig();
            ErcConfig.Open(ErcDate);
            InputDir = (string)ErcConfig["SalaryDir"] + "\\IN\\";
            break;
        }

        case    WorkModes.OPENGATE:
        {
            SeanceNum = ( int )CCommon.IsNull(Command.GetScalar(" exec dbo.pMega_OpenGate_Days;4  @TaskCode='OpenGate',@ParamCode='NumSeance' "), (int)0);
            ErcConfig = new   COpenwayConfig();
            ErcConfig.Open(ErcDate);
            InputDir = (string)ErcConfig["InputDir"];
            break;
        }

        case    WorkModes.SAKR:
        case    WorkModes.ERC:
        {
            SeanceNum = ( int )CCommon.IsNull(Command.GetScalar(" exec dbo.pMega_OpenGate_Days;4  @TaskCode='ErcGate',@ParamCode='NumSeance' "), (int)0);
            ErcConfig = new   CErcConfig();
            ErcConfig.Open(ErcDate);
            InputDir = (string)ErcConfig["InputDir"];
            break;
        }

        default:
        {
            CCommon.Print("", "Ошибка в строке параметров программы ! ");
            return;

            break;
        }
        }
        if (!ErcConfig.IsValid())
        {
            CCommon.Print("  Ошибка чтения настроек программы из " + ErcConfig.Config_FileName());
            System.Console.WriteLine(ErcConfig.ErrInfo());
            return;
        }
        if (SeanceNum < 1)
        {
            CCommon.Print(" Ошибка определения номера сеанса ");
            return;
        }
        TodayDir = (string)ErcConfig.TodayDir();
        TmpDir   = (string)ErcConfig.TmpDir();
        StatDir  = (string)ErcConfig.StatDir();
        if ((TodayDir == null) || (InputDir == null))
        {
            CCommon.Print("  Ошибка чтения настроек программы из " + ErcConfig.Config_FileName());
            return;
        }
        TodayDir = TodayDir.Trim();
        InputDir = InputDir.Trim();
        if ((TodayDir == "") || (InputDir == ""))
        {
            CCommon.Print("  Ошибка чтения настроек программы из " + ErcConfig.Config_FileName());
            return;
        }
        if (!CCommon.DirExists(StatDir))
        {
            CCommon.MkDir(StatDir);
        }
        if (!CCommon.SaveText(StatDir + "\\" + "test.dat", "test.dat", CAbc.CHARSET_DOS))
        {
            CCommon.Print(" Ошибка записи в каталог " + StatDir);
            return;
        }
        CCommon.DeleteFile(StatDir + "\\" + "test.dat");
        LogFileName = ErcConfig.LogDir() + "\\"
                      + ((WorkMode == WorkModes.CHECK)
                                        ?       "W" + CCommon.Hour(CCommon.Now()).ToString("00") + CCommon.Minute(CCommon.Now()).ToString("00") + CCommon.Second(CCommon.Now()).ToString("00")
                                        :       "SEANS" + SeanceNum.ToString("000")
                         )
                      + ".TXT";
        CCommon.Print("  Беру настройки шлюза здесь :  " + ErcConfig.Config_FileName());
        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // основной блог работы программы
        switch (WorkMode)
        {
        // - - - - - - - - - - - - - - - - - - - - - - -
        // Загружаем сторонние платежи
        case    WorkModes.SAKR:
        {
            foreach (string FName in CCommon.GetFileList(InputDir + "!A??_*.*"))
            {
                if (FName != null)
                {
                    if (FileName.Trim() != "")
                    {
                        ProcessAFile(Command, FileName, false);
                    }
                }
            }
            // Загружаем допреквизиты
            foreach (string FName in CCommon.GetFileList(InputDir + "!E*.*"))
            {
                if (FName != null)
                {
                    if (FName.Trim() != "")
                    {
                        if (ErcEFile.Load(Command, FileName))
                        {
                            CCommon.MoveFile(FileName, TodayDir + CAbc.SLASH + CCommon.GetFileName(FileName));
                        }
                    }
                }
            }
            // Завершающие действия
            CCommon.Print("  Пересчет промежуточных данных ...");
            Command.Execute("exec dbo.pMega_OpenGate_PalvisBind ");
            break;
        }

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // Загружаем коммунальные платежи из файла, который выбирает пользователь
        case    WorkModes.ERC:
        {
            FileName = SelectFileName(InputDir + "!A*.*");
            while (FileName != "")
            {
                if (ErcAFile.UserAccepted(FileName))
                {
                    ProcessAFile(Command, FileName, true);
                }
                FileName = SelectFileName(InputDir + "!A*.*");
            }
            break;
        }

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // Загружаем зарплатные платежи из файла, который выбирает пользователь
        case    WorkModes.SALARY:
        {
            FileName = SelectFileName(InputDir + "!A*.Z*");
            while (FileName != "")
            {
                if (ErcAFile.UserAccepted(FileName))
                {
                    ProcessAFile(Command, FileName, true);
                }
                FileName = SelectFileName(InputDir + "!A*.*");
            }
            break;
        }

        // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        // Загружаем платежи по универсальному шлюзу из файла, который выбирает пользователь
        case    WorkModes.OPENGATE:
        {
            if (FileName != "")
            {
                if (CCommon.FileExists(FileName))
                {
                    if (ErcAFile.UserAccepted(FileName))
                    {
                        ProcessAFile(Command, FileName, true);
                    }
                }
            }
            else
            {
                FileName = SelectFileNameGUI(SettingsDir, InputDir);
                if (FileName != "")
                {
                    if (ErcAFile.UserAccepted(FileName))
                    {
                        ProcessAFile(Command, FileName, true);
                        if (CCommon.FileExists(FileName))
                        {
                            CCommon.DeleteFile(FileName);
                        }
                    }
                }
            }
            break;
        }

        // - - - - - - - - - - - -
        // Только проверка файла
        case    WorkModes.CHECK:
        {
            string AboutError = "";
            if (FileName.Length > 0)
            {
                if (!CCommon.FileExists(FileName))
                {
                    CCommon.Print("", "Не найден файл " + FileName);
                    FileName = "";
                }
            }
            if (FileName != "")
            {
                Err.LogToConsole();
                AboutError = ErcAFile.Check(Command, FileName);
                CConsole.Clear();
                if (AboutError == "")
                {
                    CCommon.Print("", " " + ErcAFile.String_Count.ToString() + " строк на общую суммму "
                                  + CCommon.StrN(ErcAFile.Total_Credit, 11).Replace(",", "."), ""
                                  , " Ошибок не найдено.");
                }
                else
                {
                    CCommon.AppendText(LogFileName, CCommon.Now() + "   " + CCommon.Upper(CCommon.GetUserName()) + "  проверяет файл "
                                       + CCommon.GetFileName(FileName) + CAbc.CRLF + CAbc.CRLF + AboutError + CAbc.CRLF, CAbc.CHARSET_WINDOWS);
                    CCommon.Print(AboutError);
                }
            }
            else
            {
                FileName = SelectFileNameGUI(SettingsDir, InputDir);
                if (FileName != "")
                {
                    if (ErcAFile.UserAccepted(FileName))
                    {
                        AboutError = ErcAFile.Check(Command, FileName);
                        CConsole.Clear();
                        if (AboutError == "")
                        {
                            CCommon.Print("", " " + ErcAFile.String_Count.ToString() + " строк на общую суммму "
                                          + CCommon.StrN(ErcAFile.Total_Credit, 11).Replace(",", "."), ""
                                          , " Ошибок не найдено.");
                        }
                        else
                        {
                            CCommon.AppendText(LogFileName, CCommon.Now() + "   " + CCommon.Upper(CCommon.GetUserName()) + "  проверяет файл "
                                               + CCommon.GetFileName(FileName) + CAbc.CRLF + CAbc.CRLF + AboutError + CAbc.CRLF, CAbc.CHARSET_WINDOWS);
                            CCommon.Print(AboutError);
                        }
                    }
                    if (CCommon.FileExists(FileName))
                    {
                        CCommon.DeleteFile(FileName);
                    }
                }
            }
            break;
        }

        // - - - - - - - - - - - - - - - - - -
        // `запретить` заготовки из А-файла
        case    WorkModes.DISABLE:
        {
            CConsole.Clear();
            Err.LogToConsole();
            if (CCommon.ParamCount() > 2)
            {
                FileName = CAbc.ParamStr[2].Trim();
            }
            if (FileName == "")
            {
                CCommon.Print("", "Не задано имя файла !");
            }
            else
            {
                FileName = CCommon.GetFileName(FileName);
                if (Command.Execute("exec dbo.pMega_OpenGate_Disable @TaskCode='OpenGate',@FileName='" + FileName + "'"))
                {
                    CCommon.Print("", "заготовки из файла  " + FileName + "  запрещены .");
                }
                else
                {
                    CCommon.Print("", "Ошибка выполнения команды на сервере !");
                }
            }
            break;
        }
        }
        Command.Close();
        Connection.Close();
    }