예제 #1
0
        public bool DelInfo(AttInfo info)
        {
            SQLiteConnection conn = new SQLiteConnection(dbPath);/* 创建数据库实例,指定文件位置 */
            SQLiteCommand    cmdQ = new SQLiteCommand();

            try
            {
                conn.Open();                                /* 打开数据库,若文件不存在会自动创建 */
                SQLiteTransaction tran = conn.BeginTransaction();
                cmdQ             = new SQLiteCommand(conn); /* 实例化SQL命令 */
                cmdQ.Transaction = tran;
                cmdQ.CommandText = "DELETE FROM attendanceRecord where " +
                                   "deviceID = @deviceID and " +
                                   "deviceName = @deviceName and " +
                                   "mac = @mac and " +
                                   "uID = @uID and " +
                                   "studentID = @studentID and " +
                                   "name = @name and " +
                                   "state = @state and " +
                                   "time = @time"; /* 设置带参SQL语句 */
                cmdQ.Parameters.AddRange(new[] {   /* 添加参数 */
                    new SQLiteParameter("@deviceID", info.deviceID),
                    new SQLiteParameter("@deviceName", info.deviceName),
                    new SQLiteParameter("@mac", info.mac),
                    new SQLiteParameter("@uID", info.uID),
                    new SQLiteParameter("@studentID", info.studentID),
                    new SQLiteParameter("@name", info.name),
                    new SQLiteParameter("@state", info.state),
                    new SQLiteParameter("@time", info.time)
                });
                cmdQ.ExecuteNonQuery();                           /* 执行查询 */
                tran.Commit();                                    /* 提交 */
                tran.Dispose();                                   /* 释放资源 */
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmdQ.Dispose();                                   /* 释放资源 */
                conn.Close();
                return(false);
            }
            cmdQ.Dispose(); /* 释放资源 */
            conn.Close();

            return(true);
        }
예제 #2
0
            protected override bool Update()
            {
                BlockReference br = Entity as BlockReference;

                br.Position = _pos;

                if (br.AttributeCollection.Count != 0)
                {
                    foreach (ObjectId id in br.AttributeCollection)
                    {
                        DBObject obj =
                            _tr.GetObject(id, OpenMode.ForRead);
                        AttributeReference ar =
                            obj as AttributeReference;

                        // Apply block transform to att def position

                        if (ar != null)
                        {
                            ar.UpgradeOpen();
                            AttInfo ai = _attInfo[ar.ObjectId];
                            ar.Position =
                                ai.Position.TransformBy(br.BlockTransform);
                            if (ai.IsAligned)
                            {
                                ar.AlignmentPoint =
                                    ai.Alignment.TransformBy(br.BlockTransform);
                            }
                            if (ar.IsMTextAttribute)
                            {
                                ar.UpdateMTextAttribute();
                            }
                        }
                    }
                }
                return(true);
            }