Exemple #1
0
        private bool IsKindOfGoodsInUsed(OleDbTransaction tran, string uid)
        {
            OleDbConnection conn;

            if (tran != null)
            {
                conn = tran.Connection;
            }
            else
            {
                conn = new OleDbConnection(this.ConnectionString);
                conn.Open();
            }

            try
            {
                bool existed = false;
                var  query   = new QueryContext(null, "SELECT TOP 1 1 FROM [Receipts] WHERE [KindOfGoodsUId] = ?")
                {
                    Connection = conn, Transaction = tran
                };
                query.Parameters.AddWithValue(uid);
                query.ExecuteReader(r => existed = r[0].ToBoolean());
                return(existed);
            }
            finally
            {
                if (tran == null)
                {
                    conn.Dispose();
                }
            }
        }
Exemple #2
0
        private bool Exists(OleDbTransaction tran, string receiptNo)
        {
            OleDbConnection conn;

            if (tran != null)
            {
                conn = tran.Connection;
            }
            else
            {
                conn = new OleDbConnection(this.ConnectionString);
                conn.Open();
            }

            try
            {
                bool existed = false;
                var  query   = new QueryContext(null, "SELECT COUNT(*) FROM [Receipts] WHERE [No] = ?")
                {
                    Connection = conn, Transaction = tran
                };
                query.Parameters.AddWithValue(receiptNo);
                query.ExecuteReader(r => existed = r[0].ToBoolean());
                return(existed);
            }
            finally
            {
                if (tran == null)
                {
                    conn.Dispose();
                }
            }
        }
Exemple #3
0
        public IEnumerable <ReceiptTankDetail> GetReceiptTankDetails(string receiptNo)
        {
            var items = new List <ReceiptTankDetail>();

            var query = new QueryContext(this.ConnectionString, "SELECT * FROM [ReceiptTankDetails] WHERE [ReceiptNo] = ?");

            query.Parameters.AddWithValue(receiptNo);
            query.ExecuteReader(r => items.Add(new ReceiptTankDetail
            {
                TankName            = r["TankName"].ToStringOrNull(),
                VolumeByHeight      = r["VolumeByHeight"].ToBoolean(),
                Height              = r["Height"].TryToNullableDecimal(),
                TemperatureOfTank   = r["TemperatureOfTank"].TryToNullableDecimal(),
                HeightOfWater       = r["HeightOfWater"].TryToNullableDecimal(),
                TemperatureMeasured = r["TemperatureMeasured"].TryToNullableDecimal(),
                DensityMeasured     = r["DensityMeasured"].TryToNullableDecimal(),
                DensityOfStandard   = r["DensityOfStandard"].TryToNullableDecimal(),
                Vcf20            = r["Vcf20"].TryToNullableDecimal(),
                Volume           = r["Volume"].TryToNullableDecimal(),
                VolumeOfWater    = r["VolumeOfWater"].TryToNullableDecimal(),
                VolumeOfStandard = r["VolumeOfStandard"].TryToNullableDecimal(),
                Mass             = r["Mass"].TryToNullableDecimal(),
            }));

            return(items);
        }
Exemple #4
0
        private bool Exists(string username)
        {
            bool existed = false;
            var  query   = new QueryContext(this.ConnectionString, "SELECT TOP 1 1 FROM [Users] WHERE [Username] = ?");

            query.Parameters.AddWithValue(username.Trim());
            query.ExecuteReader(r => existed = r[0].ToBoolean());
            return(existed);
        }
Exemple #5
0
        public bool Authorize(string username, SecureString password)
        {
            bool verified = false;

            var query = new QueryContext(this.ConnectionString, "SELECT * FROM [Users] WHERE [Username] = ?");

            query.Parameters.AddWithValue(username.Trim());
            query.ExecuteReader(r =>
            {
                verified = r["password"].ToString().Equals(CommonHelper.SecureStringToMD5(password), StringComparison.Ordinal);
            });

            return(verified);
        }
Exemple #6
0
        public Receipt Get(string receiptNo)
        {
            Receipt receipt = null;

            var query = new QueryContext(this.ConnectionString, "SELECT r.*, k.[Name] AS KindOfGoodsName FROM [Receipts] AS r LEFT OUTER JOIN [KindsOfGoods] AS k ON r.KindOfGoodsUId = k.[UId] WHERE r.[No] = ?");

            query.Parameters.AddWithValue(receiptNo);
            query.ExecuteReader(r => receipt = this.ReadReceipt(r));

            if (receipt == null)
            {
                throw new KeyNotFoundException(String.Format("Receipt No.: \"{0}\" not found", receiptNo));
            }

            receipt.ReceiptTankDetails.AddRange(this.GetReceiptTankDetails(receiptNo));
            return(receipt);
        }