Пример #1
0
 void GetHeaderYear()
 {
     if (damaiDataSet.VEHeader.Rows.Count > 0)   // Header內容在ReadFile 讀進來了
     {
         DamaiDataSet.VEHeaderRow headerRow = damaiDataSet.VEHeader[0];
         if (headerRow != null)
         {
             string str;
             str = headerRow.DataYear.Year.ToString().Trim();
             if (str != "")
             {
                 MyFunction.HeaderYear = str;
             }
             MyFunction.IntHeaderYear  = headerRow.DataYear.Year;
             MyFunction.LockAll        = headerRow.Closed;
             MyFunction.IntHeaderMonth = headerRow.DataYear.Month;
         }
     }
 }
Пример #2
0
        private bool ReadTable()
        {
            operatorSQLAdapter  = new DamaiDataSetTableAdapters.OperatorTableAdapter();
            headerSQLAdapter    = new DamaiDataSetTableAdapters.VEHeaderTableAdapter();
            apartmentSQLAdapter = new DamaiDataSetTableAdapters.ApartmentTableAdapter();
            authListSQLAdapter  = new DamaiDataSetTableAdapters.OperatorAuthListTableAdapter();

            operatorSQLAdapter.Connection.ConnectionString  = DB.SqlConnectString(m_Cfg);
            apartmentSQLAdapter.Connection.ConnectionString = DB.SqlConnectString(m_Cfg);
            authListSQLAdapter.Connection.ConnectionString  = DB.SqlConnectString(m_Cfg);

            damaiDataSet = new DamaiDataSet();
            try
            {
                operatorSQLAdapter.Fill(damaiDataSet.Operator);
                headerSQLAdapter.Fill(damaiDataSet.VEHeader);
                apartmentSQLAdapter.Fill(damaiDataSet.Apartment);
                authListSQLAdapter.Fill(damaiDataSet.OperatorAuthList);
            }
            catch (Exception ex)
            {
                MessageBox.Show("操作員資料庫讀取錯誤<" + ex.Message + ">!  無法登入");
                return(false);
            }
            if (damaiDataSet.Operator.Rows.Count == 0)
            {
                MessageBox.Show("資料庫內沒有設定任何操作員,無法登入");
                Close();
                return(false);
            }
            if (damaiDataSet.Apartment.Rows.Count != 0)
            {
                string Key = "LordAlex";
                foreach (var a in damaiDataSet.Apartment)
                {
                    byte[] buf     = Encoder.RC2Decrypt(Convert.FromBase64String(a.DatabaseName.Trim()), Key);
                    string decoded = Encoding.Unicode.GetString(buf);
                    if (decoded == m_Cfg.Database.Trim())     // 不使用IsCurrent了
                    {
                        m_DefaultApartment = a;
                        break;
                    }
                }
                if (m_DefaultApartment == null)
                {
                    MessageBox.Show("部門資料庫內找不到<" + m_Cfg.Database + ">,設定有誤無法登入,請找IT帥哥!");
#if (DEBUG)
                    m_DefaultApartment = damaiDataSet.Apartment[9];
#else
                    Close();
                    return(false);
#endif
                }
            }

            DamaiDataSet.VEHeaderRow header = null;
            string sVersion = "";
            if (damaiDataSet.VEHeader.Count > 0)
            {
                header = damaiDataSet.VEHeader[0];
                if (!header.IsVersionNull())
                {
                    sVersion = header.Version.Trim();
                }
            }
            CheckAppVersion(sVersion);
            return(true);
        }