Ejemplo n.º 1
0
        public override void Save(ParMainLite _O)
        {
            L.Clear();
            ExecSave(_O, (_O as IParentBase).PropertyName);
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms, Encoding.GetEncoding(1251));

            foreach (Param p in L)
            {
                sw.WriteLine(p.ToString());
            }
            sw.Flush();
            string img = Encoding.GetEncoding(1251).GetString(ms.ToArray());

            sw.Dispose();
            ms.Dispose();
            ExecSQLX E = new ExecSQLX(string.Format("update {0} set Val=@textdata where Unit='{1}'",
                                                    schema + "." + table_name, Unit));

            E.AddParam("@textdata", SqlDbType.Text, img, img.Length);
            int ret = E.Exec();

            if (ret == 0)
            {
                ExecSQLX EE = new ExecSQLX(string.Format("insert into {0} values('{1}',@textdata)",
                                                         schema + "." + table_name, Unit));
                EE.AddParam("@textdata", SqlDbType.Text, img, img.Length);
                int aaa = EE.Exec();
            }
        }
Ejemplo n.º 2
0
        public override bool Update()
        {
            ExecSQLX E = new ExecSQLX(string.Format("update {0}.SGEtalonPars set val={1} where typeSize='{2}' and sGroup='{3}' and etalon={4} and par={5}",
                                                    BaseItem.Schema,
                                                    Val.ToString().Replace(',', '.'),
                                                    ownKey.TSName,
                                                    ownKey.GroupName,
                                                    ownKey.EtalonId.ToString(),
                                                    ownKey.EtalonParsId.ToString()));

            if (E.Exec() == 1)
            {
                return(true);
            }
            else
            {
                Select S = new Select(string.Format("SELECT val from {0}.SGEtalonPars where typeSize='{1}' and sGroup='{2}' and etalon={3} and par={4}",
                                                    BaseItem.Schema,
                                                    ownKey.TSName,
                                                    ownKey.GroupName,
                                                    ownKey.EtalonId.ToString(),
                                                    ownKey.EtalonParsId.ToString()
                                                    ));
                if (!S.Read())
                {
                    throw new Exception("EtalonPars: не могу получить предыдуще значения");
                }
                Val = SD(S["val"]);
                S.Dispose();
                return(false);
            }
        }
Ejemplo n.º 3
0
        public override bool Update()
        {
            pr("Tube.Update()");
            ExecSQLX E = new ExecSQLX(string.Format("update {0}.SGTubes set dt=@dt, name='{1}', sGroup='{2}' where id={3}",
                                                    BaseItem.Schema,
                                                    Name,
                                                    SG,
                                                    Id.ToString()
                                                    ));

            E.AddParam("@dt", SqlDbType.DateTime, Dt);
            bool ret = E.Exec() == 1;

            if (!ret)
            {
                Select S = new Select(string.Format("SELECT dt, name, sGroup from {0}.SGTubes where Id={1}",
                                                    BaseItem.Schema, Id.ToString()));
                if (!S.Read())
                {
                    throw new Exception("Tube: не могу получить предыдуще значения");
                }
                Dt   = (DateTime)S["dt"];
                Name = S["name"] as string;
                SG   = S["sGroup"] as string;
                S.Dispose();
            }
            return(ret);
        }
Ejemplo n.º 4
0
        public override bool Update()
        {
            ExecSQLX E = new ExecSQLX(string.Format("update {0}.SGEtalons set dt=@dt, IsOn='{1}' where typeSize='{2}' and sGroup='{3}' and id={4}",
                                                    BaseItem.Schema,
                                                    IsOn ? "true" : "false",
                                                    ownKey.TSName,
                                                    ownKey.GroupName,
                                                    Id.ToString()));

            E.AddParam("@dt", SqlDbType.DateTime, Dt);
            pr("Update");
            bool ret = E.Exec() == 1;

            if (!ret)
            {
                Select S = new Select(string.Format("SELECT dt from {0}.SGEtalons where typeSize='{1}' and sGroup='{2}' and id={3}",
                                                    BaseItem.Schema,
                                                    ownKey.TSName,
                                                    ownKey.GroupName,
                                                    Id.ToString()
                                                    ));
                if (!S.Read())
                {
                    throw new Exception("Etalon: не могу получить предыдуще значения");
                }
                Dt   = (DateTime)S["dt"];
                IsOn = Convert.ToBoolean(S["IsOn"]);
                S.Dispose();
            }
            return(ret);
        }
Ejemplo n.º 5
0
        public override bool Update()
        {
            ExecSQLX E = new ExecSQLX(string.Format("update {0}.SGTresh set val={1} where typeSize='{2}' and Par={3}",
                                                    BaseItem.Schema,
                                                    Val.ToString().Replace(',', '.'),
                                                    ownKey.TSName,
                                                    ownKey.TreshId.ToString()
                                                    ));
            int ret = E.Exec();

            if (ret == 1)
            {
                return(true);
            }
            else
            {
                Select S = new Select(string.Format("SELECT val from {0}.SGTresh where typeSize='{1}' and Par={2}",
                                                    BaseItem.Schema,
                                                    ownKey.TSName,
                                                    ownKey.TreshId.ToString()));
                if (!S.Read())
                {
                    throw new Exception("Tresh: не могу получить предыдуще значения");
                }
                Val = SD(S["val"]);
                S.Dispose();
                return(false);
            }
        }
Ejemplo n.º 6
0
        public override bool Update()
        {
            pr("Group.Update()");
            bool ret = new ExecSQLX(string.Format("update {0}.SGroups set name='{1}',color={2}, IsOn='{3}' where typeSize='{4}' and name='{5}'",
                                                  BaseItem.Schema,
                                                  Name,
                                                  DBColor,
                                                  IsOn ? "true" : "false",
                                                  ownKey.TSName,
                                                  saved_name
                                                  )).Exec() == 1;

            if (ret)
            {
                saved_name = Name;
            }
            else
            {
                Name = saved_name;
                Select S = new Select(string.Format("SELECT * from {0}.SGroups where typeSize='{1} and name='{2}'", BaseItem.Schema, ownKey.TSName, Name));
                if (!S.Read())
                {
                    throw new Exception("Group: не могу получить предыдуще значения");
                }
                RColor = Color.FromArgb((int)S["color"]);
                IsOn   = Convert.ToBoolean(S["IsOn"]);
                S.Dispose();
            }
            return(ret);
        }
Ejemplo n.º 7
0
        public static bool Save0(string _TSName, double[] _treshPercent)
        {
            ExecSQLX E = new ExecSQLX(string.Format("delete from {0}.SGTresh where typeSize='{1}'",
                                                    BaseItem.Schema,
                                                    _TSName
                                                    ));
            int ret = E.Exec();

            if (_treshPercent == null)
            {
                return(true);
            }
            for (int i = 0; i < _treshPercent.Length; i++)
            {
                ExecSQLX EE = new ExecSQLX(string.Format("insert into {0}.SGTresh values('{1}',{2},{3})",
                                                         BaseItem.Schema, _TSName, i.ToString(), _treshPercent[i].ToString().Replace(',', '.')));
                if (EE.Exec() != 1)
                {
                    return(false);
                }
            }
            new ExecSQLX(string.Format(
                             " UPDATE x SET x.par = x.new_par FROM (" +
                             " SELECT par, ROW_NUMBER() OVER (ORDER BY val)-1  AS new_par" +
                             " FROM {0}.SGTresh where typeSize='{1}' ) x",
                             BaseItem.Schema, _TSName)).Exec();
            return(true);
        }
Ejemplo n.º 8
0
        public override bool Update()
        {
            ExecSQLX E = new ExecSQLX(string.Format("update {0}.SGTubePars set val={1} where tube_id={2} and Par={3}",
                                                    BaseItem.Schema,
                                                    Val.ToString().Replace(',', '.'),
                                                    ownKey.TubeId.ToString(),
                                                    ownKey.TubeParsId.ToString()));

            if (E.Exec() == 1)
            {
                return(true);
            }
            else
            {
                Select S = new Select(string.Format("SELECT val from {0}.SGTubePars where tube_id={1} and Par={2}",
                                                    BaseItem.Schema,
                                                    ownKey.TubeId.ToString(),
                                                    ownKey.TubeParsId.ToString()
                                                    ));
                if (!S.Read())
                {
                    throw new Exception("TubePars: не могу получить предыдуще значения");
                }
                Val = SD(S["val"]);
                S.Dispose();
                return(false);
            }
        }
Ejemplo n.º 9
0
        protected override bool SetImg(string _data)
        {
            ExecSQLX E = new ExecSQLX(string.Format("update {0}.SGEtalons set img=@textdata where typesize='{1}' and sGroup='{2}' and id={3}",
                                                    BaseItem.Schema, ownKey.TSName, ownKey.GroupName, Id.ToString()));

            E.AddParam("@textdata", SqlDbType.Text, _data, _data.Length);
            return(E.Exec() == 1);
        }
Ejemplo n.º 10
0
        protected override bool SetImg(string _data)
        {
            ExecSQLX E = new ExecSQLX(string.Format("update {0}.SGTubes set img=@textdata where id={1}",
                                                    BaseItem.Schema, Id.ToString()));

            E.AddParam("@textdata", SqlDbType.Text, _data, _data.Length);
            return(E.Exec() == 1);
        }
Ejemplo n.º 11
0
 public static bool Save(Int64 _TubeId, double[] _mval)
 {
     new ExecSQLX(string.Format("delete from {0}.SGTubePars where tube_id={1}", BaseItem.Schema, _TubeId.ToString())).Exec();
     for (int i = 0; i < _mval.Length; i++)
     {
         ExecSQLX E = new ExecSQLX(string.Format("insert into {0}.SGTubePars values({1},{2},{3})",
                                                 BaseItem.Schema, _TubeId.ToString(), i.ToString(), _mval[i].ToString().Replace(',', '.')));
         if (E.Exec() != 1)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 12
0
        public override bool Update()
        {
            pr("TypeSize.Update()");
            bool ret = new ExecSQLX(string.Format("update {0}.SGTypeSizes set name='{1}' where name='{2}'", BaseItem.Schema, Name, saved_name)).Exec() == 1;

            if (ret)
            {
                saved_name = Name;
            }
            else
            {
                Name = saved_name;
            }
            return(ret);
        }
Ejemplo n.º 13
0
 public static bool Save(string _TSName, string _GroupName, int _EtalonId, double[] _mval)
 {
     new ExecSQLX(string.Format("delete from {0}.SGEtalonPars where typeSize='{1}' and sGroup='{2}' and etalon={3}",
                                BaseItem.Schema, _TSName, _GroupName, _EtalonId.ToString())).Exec();
     for (int i = 0; i < _mval.Length; i++)
     {
         ExecSQLX E = new ExecSQLX(string.Format("insert into {0}.SGEtalonPars values('{1}','{2}',{3},{4},{5})",
                                                 BaseItem.Schema, _TSName, _GroupName, _EtalonId.ToString(), i.ToString(), _mval[i].ToString().Replace(',', '.')));
         if (E.Exec() != 1)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 14
0
        public override void UpdateSOP(SOPPars _sop)
        {
            SOP = _sop == null ? null : _sop.Name;
            ExecSQLX E = new ExecSQLX(string.Format("update {0}.SGTubes set SOP={1} where id={2}",
                                                    BaseItem.Schema,
                                                    SOP == null ? "null" : "'" + SOP + "'",
                                                    Id.ToString()
                                                    ));
            bool ret = E.Exec() == 1;

            if (!ret)
            {
                throw new Exception("Tube: не могу записать SOP");
            }
        }
Ejemplo n.º 15
0
        public override void UpdateSOP(SOPPars _sop)
        {
            SOP = _sop == null ? null : _sop.Name;
            ExecSQLX E = new ExecSQLX(string.Format("update {0}.SGEtalons set SOP={1} where typeSize='{2}' and sGroup='{3}' and id={4}",
                                                    BaseItem.Schema,
                                                    SOP == null ? "null" : "'" + SOP + "'",
                                                    ownKey.TSName,
                                                    ownKey.GroupName,
                                                    Id.ToString()));
            bool ret = E.Exec() == 1;

            if (!ret)
            {
                throw new Exception("Etalon: не могу записать SOP");
            }
        }
Ejemplo n.º 16
0
        public override bool Delete()
        {
            int ret = new ExecSQLX(string.Format("delete from {0}.SGTresh where typeSize='{1}' and Par={2}",
                                                 BaseItem.Schema,
                                                 ownKey.TSName,
                                                 ownKey.TreshId.ToString())).Exec();

            if (ret != 1)
            {
                return(false);
            }
            new ExecSQLX(string.Format(
                             " UPDATE x SET x.par = x.new_par FROM (" +
                             " SELECT par, ROW_NUMBER() OVER (ORDER BY [par]) - 1  AS new_par" +
                             " FROM {0}.SGTresh where typeSize='{1}' ) x",
                             BaseItem.Schema,
                             ownKey.TSName)).Exec();
            return(true);
        }
Ejemplo n.º 17
0
 internal void Save(LParam _L)
 {
     CDBS.BeginTransaction();
     try
     {
         new ExecSQLX(string.Format("delete from {0}", s_table)).Exec();
         foreach (Param p in _L)
         {
             ExecSQLX E = new ExecSQLX(string.Format("insert into {0} values('{1}','{2}')", s_table, p.path.Replace('[', '{').Replace(']', '}'), p.val));
             if (E.Exec() != 1)
             {
                 CDBS.RollBack();
                 throw new Exception("Не смогли записать настройки в базу");
             }
         }
     }
     catch
     {
         CDBS.RollBack();
         throw new Exception("Не смогли записать настройки в базу");
     }
     CDBS.Commit();
 }