Exemplo n.º 1
0
        public WorkingDataBase[] ALL(String AppName)
        {
            var sql = @"SELECT [DBID]
                      ,[DBName]
                      ,[DBYear]
                      ,[DBSysName]
                      ,[IsActive]
                      ,[WorkDataBase].[DBNo]
                      ,[pwd1]
                      ,[pwd2]
                      ,[pwd3]
                      ,[pwd4]
                      ,[pwd5]
                      ,[UserName]
                      ,[CompanyName]
                      ,[ServerIp]
                      ,[IsLocal]
                  FROM  [WorkDataBase] join [DB_AppDB] on [WorkDataBase].[DBNo]=[DB_AppDB].[DBNo]
                    join [DB_App] on ([DB_App].[BO_Id]=[DB_AppDB].[App_Id] and [BO_AppName]='" + AppName + @"') ORDER BY [WorkDataBase].DBNo";
            var r   = new SqlCon(this.SqlCon).GetTable(sql);
            List <WorkingDataBase> result = new List <WorkingDataBase>();

            try
            {
                foreach (DataRow i in r.Rows)
                {
                    result.Add(new WorkingDataBase(i));
                }
                return(result.ToArray());
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 2
0
 public   WorkingDataBase[] ALLList()
 {
     if (allList != null)
     {
         return(allList.ToArray());
     }
     else
     {
         allList = new List <WorkingDataBase>();
         var sql = @"SELECT [DBID]
               ,[DBName]
               ,[DBYear]
               ,[DBSysName]
               ,[IsActive]
               ,[WorkDataBase].[DBNo]
               ,[pwd1]
               ,[pwd2]
               ,[pwd3]
               ,[pwd4]
               ,[pwd5]
               ,[UserName]
               ,[CompanyName]
               ,[ServerIp]
               ,[IsLocal]
           FROM  [WorkDataBase] ORDER BY DBNo";
         var r   = new SqlCon().GetTable(sql);
         //       List<WorkingDataBase> result = new List<WorkingDataBase>();
         try
         {
             foreach (DataRow i in r.Rows)
             {
                 allList.Add(new WorkingDataBase(i));
             }
             return(allList.ToArray());
         }
         catch (Exception ex)
         {
             return(null);
         }
     }
 }
Exemplo n.º 3
0
        public void Reload()
        {
            var sql = @"Select [DBID]
      ,[DBName]
      ,[DBYear]
      ,[DBSysName]
      ,[IsActive]
      ,[DBNo]
      ,[pwd1]
      ,[pwd2]
      ,[pwd3]
      ,[pwd4]
      ,[pwd5]
      ,[UserName]
      ,[CompanyName]
      ,[ServerIp]
  FROM [WorkDataBase] Where [DBNo]='" + this.Code + "'";
            var q   = new SqlCon().GetTable(sql);

            if (q.Rows.Count > 0)
            {
                Init(q.Rows[0]);
            }
        }
Exemplo n.º 4
0
        public void Create(WorkingDataBase db)
        {
            //using (DBDataDataContext contect = DBDataDataContext.Instance)
            //{

            String selectSql = "Select [DBID] from [WorkDataBase] Where [DBName]='" + db.Name + "' And [DBYear]='" + db.Year + "'";

            if (new SqlCon().GetTable(selectSql).Rows.Count > 0)
            {
                throw new Exception("不能创建名称,年度相同的帐套");
            }
            else
            {
                var NoSql = "Select Max(DBNo) from  [WorkDataBase]";

                var    noTable = new SqlCon().GetTable(NoSql);
                var    topno   = noTable.Rows[0][0];
                String dbNo;
                if (topno == null ||
                    (topno is DBNull))
                {
                    dbNo = "01";
                }
                else
                {
                    dbNo = (System.Convert.ToInt32(topno.ToString()) + 1).ToString().PadLeft(2, '0');
                }


                EncryptionClass entry = new EncryptionClass(db.PassWord);
                //user.pwd1 = entry.EncrKey;
                //user.pwd2 = entry.EnIndex;
                //user.pwd3 = entry.IV;
                //user.pwd4 = entry.IvIndex;
                //user.pwd5 = entry.EncryString;

                String InsertSql = @"INSERT INTO  [WorkDataBase]
           ([DBName]
           ,[DBYear]
           ,[DBSysName]
           ,[IsActive]
           ,[DBNo]
           ,[pwd1]
           ,[pwd2]
           ,[pwd3]
           ,[pwd4]
           ,[pwd5]
           ,[UserName]
           ,[CompanyName]
           ,[ServerIp])
     VALUES
           ('" + db.Name + @"'
           ,'" + db.Year + @"'
           ,'" + db.SysName + @"'
           ,'" + System.Convert.ToInt32(db.IsActive).ToString() + @"'
           ,'" + dbNo + @"'
           ," + ByteToString(entry.EncrKey) + @"
           ," + ByteToString(entry.EnIndex) + @"
           ," + ByteToString(entry.IV) + @"
           ," + ByteToString(entry.IvIndex) + @"
           ,'" + entry.EncryString + @"'
           ,'" + db.UserName + @"'
             ,'" + db.CompanyName + @"'
           ,'" + db.ServerIp + @"')";
                new SqlCon().ExcuteSql(InsertSql);
            }
//                WorkDataBase user = new WorkDataBase();
//                var q = from db1 in contect.WorkDataBases
//                        where db1.DBName == db.Name
//                        && db.Year == db1.DBYear
//                        select db1 ;
//                if (q.Count() > 0)
//                {
//                    throw new Exception("不能创建名称,年度相同的帐套");
//                }
//                  var q2=contect.WorkDataBases ;
//                    if (q2.Count() > 0)
//                    {
//                        user.DBNo  = (System.Convert.ToInt32(q2.Max(p => p.DBNo ))+1).ToString().PadLeft(2, '0');
//                    }
//                    else
//                        user.DBNo  =  "01";


//                user.UserName = db.UserName;
//                user.DBYear = db.Year;
//                user.DBSysName = db.SysName;
//                user.IsActive = db.IsActive;
//                user.DBName = db.Name;

//                EncryptionClass entry = new EncryptionClass(db.PassWord);
//                user.pwd1 = entry.EncrKey;
//                user.pwd2 = entry.EnIndex;
//                user.pwd3 = entry.IV;
//                user.pwd4 = entry.IvIndex;
//                user.pwd5 = entry.EncryString;

//                contect.WorkDataBases.InsertOnSubmit(user);
//                contect.SubmitChanges();
//            }
        }