Пример #1
0
 Etalon(Group.DBKey _parentKey, int _Id, DateTime _Dt, string _SOP, bool _IsOn)
     : base(_parentKey.TSName)
 {
     ownKey = new DBKey(_parentKey, _Id);
     Dt     = _Dt;
     SOP    = _SOP;
     IsOn   = _IsOn;
 }
Пример #2
0
        public static bool InsertKey(BaseDBKey _Key, BindingSource _bs)
        {
            if (_Key == null)
            {
                return(false);
            }
            Group.DBKey Key    = _Key as Group.DBKey;
            int         new_id = FindNewId(_bs);
            Select      S      = new Select(string.Format("insert into {0}.SGEtalons (typeSize,sGroup,id) output inserted.dt values('{1}','{2}',{3})",
                                                          BaseItem.Schema, Key.TSName, Key.GroupName, new_id.ToString()));
            bool ret = S.Read();

            if (ret)
            {
                _bs.Position = _bs.Add(new Etalon(Key, new_id, (DateTime)S["dt"], null, true));
            }
            S.Dispose();
            return(ret);
        }
Пример #3
0
        public static void LoadKey(BaseDBKey _Key, BindingSource _bs)
        {
            _bs.Clear();
            if (_Key == null)
            {
                return;
            }
            Group.DBKey Key = _Key as Group.DBKey;
            Select      S   = new Select(string.Format("SELECT id, dt, sop, IsOn from {0}.SGEtalons where typeSize='{1}' and sGroup='{2}' order by id",
                                                       BaseItem.Schema,
                                                       Key.TSName,
                                                       Key.GroupName
                                                       ));

            while (S.Read())
            {
                _bs.Add(new Etalon(Key, (int)S["id"], (DateTime)S["dt"], S["SOP"] as string, Convert.ToBoolean(S["IsOn"])));
            }
            S.Dispose();
        }
Пример #4
0
        public static int TubeToEtalon(Tube _tb, Group.DBKey _gKey)
        {
            if (_gKey == null)
            {
                return(-1);
            }
            string SQL = string.Format(
                "insert {0}.SGEtalons output Inserted.ID" +
                " select '{1}','{2}'," +
                " (select isnull(max(id)+1,0) from {0}.SGEtalons where typeSize='{1}'and sGroup='{2}')" +
                " ,t.dt, t.sop, 'True', t.img" +
                " from Uran.SGTubes t where t.id={3}",
                BaseItem.Schema,
                _gKey.TSName,
                _gKey.GroupName,
                _tb.Id.ToString());
            Select S = new Select(SQL);

            if (!S.Read())
            {
                S.Dispose();
                return(-1);
            }
            int new_id = (int)S["id"];

            S.Dispose();
            SQL = string.Format(
                "insert {0}.SGEtalonPars" +
                " select '{1}','{2}',{3},p.par,p.val" +
                " from {0}.SGTubePars p" +
                " where p.tube_id={4}",
                BaseItem.Schema,
                _gKey.TSName,
                _gKey.GroupName,
                new_id.ToString(),
                _tb.Id.ToString());
            new ExecSQLX(SQL).Exec();
            return(new_id);
        }
Пример #5
0
 private void dg_DragDrop(object sender, DragEventArgs e)
 {
     if (DragTo)
     {
         Tube        tb     = e.Data.GetData(typeof(Tube)) as Tube;
         Group.DBKey gKey   = parentKey as Group.DBKey;
         int         new_id = Etalon.TubeToEtalon(tb, gKey);
         if (new_id < 0)
         {
             prs("Не удалось записать трубу в эталон");
             return;
         }
         RLoad();
         foreach (Etalon o in bs)
         {
             if (o.Id == new_id)
             {
                 bs.Position = bs.IndexOf(o);
                 break;
             }
         }
     }
 }
Пример #6
0
 public DBKey(Group.DBKey _parentKey, int _Id)
     : base(_parentKey)
 {
     EtalonId = _Id;
 }