示例#1
0
文件: Day.cs 项目: shkumat/mgb_day
    // - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    //	Вычитка списка пунктов открытия/закрытия дня
    static bool    LoadHistory(int Mode)
    {
        int MenuItemWidth = (Mode == 1) ? 32 : 25;

        Connection = new CConnection(ConnectionString);
        RecordSet  = new   CRecordSet(Connection);
        bool Result = false;

        if (RecordSet.Open("exec Mega_Day_Close;10  @DayDate=" + DayDate.ToString() + " , @Mode= " + Mode.ToString()))
        {
            while (RecordSet.Read())
            {
                if (CCommon.CInt(RecordSet["Cnt"]) == 0)
                {
                    MNames.Add(CCommon.Left(RecordSet["Name"], MenuItemWidth) + "*");
                }
                else
                {
                    MNames.Add(CCommon.Left(RecordSet["Name"], MenuItemWidth) + "* " + RecordSet["Cnt"].Trim());
                }
                MCommands.Add(RecordSet["Command"]);
                MParams.Add(RecordSet["Params"]);
                MKinds.Add(RecordSet["Kind"]);
                Result = true;
            }
        }
        else
        {
            Result = false;
        }
        RecordSet.Close();
        int MenuCount = MNames.Count;

        MenuNames    = new   string[MenuCount];
        MenuKinds    = new   string[MenuCount];
        MenuParams   = new   string[MenuCount];
        MenuCommands = new   string[MenuCount];
        MenuCount    = 0;
        foreach (string MenuName in MNames)
        {
            MenuNames[MenuCount++] = MenuName;
        }
        MenuCount = 0;
        foreach (string MenuKind in MKinds)
        {
            MenuKinds[MenuCount++] = MenuKind;
        }
        MenuCount = 0;
        foreach (string MenuParam in MParams)
        {
            MenuParams[MenuCount++] = MenuParam;
        }
        MenuCount = 0;
        foreach (string MenuCommand in MCommands)
        {
            MenuCommands[MenuCount++] = MenuCommand;
        }
        MCommands.Clear();
        MParams.Clear();
        MKinds.Clear();
        MNames.Clear();
        Connection.Close();
        return(Result);
    }