Exemple #1
0
        public static void PLC_ValueMng_Save(string PLCType, string AddType, DataTable dtMng)
        {
            if (AddType == null || AddType.Equals(string.Empty))
            {
                return;
            }

            Function.Db.SQLite db = new Function.Db.SQLite(sqldb_path);

            try
            {
                db.BeginTransaction();

                string sql = string.Format(@"DELETE FROM PLC_Value_Mng
WHERE PLCTYPE = '{0}'
AND ADDTYPE = '{1}'", PLCType, AddType);

                db.intExcute_Query(sql);

                foreach (DataRow dr in dtMng.Rows)
                {
                    sql = string.Format(@"INSERT INTO PLC_Value_Mng(
PLCType, ADDType, Priority, 
Mng_Type, Address, Address_Length, 
Value, ValueType, Condition, 
isUse, Desc)
VALUES 
( '{0}', '{1}', {2},
'{3}', '{4}', '{5}',
'{6}', '{7}', '{8}',
'{9}', '{10}' )", PLCType, AddType, dr["Priority"],
                                        dr["Mng_Type"], dr["Address"], dr["Address_Length"],
                                        dr["Value"], dr["ValueType"], dr["Condition"],
                                        dr["isUse"], dr["Desc"]);

                    db.intExcute_Query(sql);
                }

                db.CommitTransaction();
            }
            catch
            {
                db.RollBackTransaction();
                throw;
            }
        }
Exemple #2
0
        public static void Address_Set(string PLCType, string AddType, DataTable dtAdd)
        {
            if (AddType == null || AddType.Equals(string.Empty))
            {
                return;
            }

            Function.Db.SQLite db = new Function.Db.SQLite(sqldb_path);

            try
            {
                db.BeginTransaction();

                string sql = string.Format(@"DELETE FROM PLC_Addresses
WHERE PLCTYPE = '{0}'
AND ADDTYPE = '{1}'", PLCType, AddType);

                db.intExcute_Query(sql);

                foreach (DataRow dr in dtAdd.Rows)
                {
                    sql = string.Format(@"INSERT INTO PLC_Addresses(
PLCType, ADDType, Address,
Value, HexValue, Priority,
Desc, Desc2, AddGroup)
VALUES 
( '{0}', '{1}', '{2}',
'{3}', '{4}', {5},
'{6}', '{7}', '{8}' )", PLCType, AddType, dr["Address"],
                                        dr["Value"], dr["hexValue"], dr["Priority"],
                                        dr["Desc"], dr["Desc2"], dr["AddGroup"]);

                    db.intExcute_Query(sql);
                }

                db.CommitTransaction();
            }
            catch
            {
                db.RollBackTransaction();
                throw;
            }
        }