public List <ProductWarehouseDetail> LoadProductWarehouseDetailsByCreatedBy(string createdBy)
        {
            string     sql = @"SELECT [DetailID]
				, [InID]
				, [PackageID]
				, [LocationID]
				, [Created]
				, [CreatedBy]
				 FROM [BE_ProductWarehouseDetail] WHERE [CreatedBy]=@CreatedBy"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pCreatedBy = new SqlParameter("CreatedBy", createdBy);

            pCreatedBy.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pCreatedBy);

            List <ProductWarehouseDetail> ret = new List <ProductWarehouseDetail>();
            SqlDataReader dr = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    ProductWarehouseDetail iret = new ProductWarehouseDetail();
                    if (!Convert.IsDBNull(dr["DetailID"]))
                    {
                        iret.DetailID = (Guid)dr["DetailID"];
                    }
                    if (!Convert.IsDBNull(dr["InID"]))
                    {
                        iret.InID = (Guid)dr["InID"];
                    }
                    if (!Convert.IsDBNull(dr["PackageID"]))
                    {
                        iret.PackageID = (Guid)dr["PackageID"];
                    }
                    if (!Convert.IsDBNull(dr["LocationID"]))
                    {
                        iret.LocationID = (Guid)dr["LocationID"];
                    }
                    if (!Convert.IsDBNull(dr["Created"]))
                    {
                        iret.Created = (DateTime)dr["Created"];
                    }
                    iret.CreatedBy = dr["CreatedBy"].ToString();
                    ret.Add(iret);
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }
        public int LoadProductWarehouseDetailByDetailID(ProductWarehouseDetail obj)
        {
            string     sql = @"SELECT [DetailID]
				, [InID]
				, [PackageID]
				, [LocationID]
				, [Created]
				, [CreatedBy]
                FROM [BE_ProductWarehouseDetail] WITH(NOLOCK) WHERE [DetailID]=@DetailID"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pDetailID = new SqlParameter("DetailID", Convert2DBnull(obj.DetailID));

            pDetailID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pDetailID);

            int           ret = 0;
            SqlDataReader dr  = cmd.ExecuteReader();

            try
            {
                while (dr.Read())
                {
                    if (!Convert.IsDBNull(dr["DetailID"]))
                    {
                        obj.DetailID = (Guid)dr["DetailID"];
                    }
                    if (!Convert.IsDBNull(dr["InID"]))
                    {
                        obj.InID = (Guid)dr["InID"];
                    }
                    if (!Convert.IsDBNull(dr["PackageID"]))
                    {
                        obj.PackageID = (Guid)dr["PackageID"];
                    }
                    if (!Convert.IsDBNull(dr["LocationID"]))
                    {
                        obj.LocationID = (Guid)dr["LocationID"];
                    }
                    if (!Convert.IsDBNull(dr["Created"]))
                    {
                        obj.Created = (DateTime)dr["Created"];
                    }
                    obj.CreatedBy = dr["CreatedBy"].ToString();
                    ret          += 1;
                }
            }
            finally
            {
                dr.Close();
            }
            return(ret);
        }
        public int InsertProductWarehouseDetail(ProductWarehouseDetail obj)
        {
            string     sql = @"INSERT INTO[BE_ProductWarehouseDetail]([DetailID]
				, [InID]
				, [PackageID]
				, [LocationID]
				, [Created]
				, [CreatedBy]
				) VALUES(@DetailID
				, @InID
				, @PackageID
				, @LocationID
				, @Created
				, @CreatedBy
				)"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pDetailID = new SqlParameter("DetailID", Convert2DBnull(obj.DetailID));

            pDetailID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pDetailID);

            SqlParameter pInID = new SqlParameter("InID", Convert2DBnull(obj.InID));

            pInID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pInID);

            SqlParameter pPackageID = new SqlParameter("PackageID", Convert2DBnull(obj.PackageID));

            pPackageID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pPackageID);

            SqlParameter pLocationID = new SqlParameter("LocationID", Convert2DBnull(obj.LocationID));

            pLocationID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pLocationID);

            SqlParameter pCreated = new SqlParameter("Created", Convert2DBnull(obj.Created));

            pCreated.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pCreated);

            SqlParameter pCreatedBy = new SqlParameter("CreatedBy", Convert2DBnull(obj.CreatedBy));

            pCreatedBy.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pCreatedBy);

            return(cmd.ExecuteNonQuery());
        }
        public int UpdateProductWarehouseDetailByDetailID(ProductWarehouseDetail obj)
        {
            string     sql = @"UPDATE [BE_ProductWarehouseDetail] SET [InID]=@InID
				, [PackageID]=@PackageID
				, [LocationID]=@LocationID
				, [Created]=@Created
				, [CreatedBy]=@CreatedBy
                WHERE [DetailID]=@DetailID"                ;
            SqlCommand cmd = new SqlCommand(sql, this.conn, this.trans);

            SqlParameter pInID = new SqlParameter("InID", Convert2DBnull(obj.InID));

            pInID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pInID);

            SqlParameter pPackageID = new SqlParameter("PackageID", Convert2DBnull(obj.PackageID));

            pPackageID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pPackageID);

            SqlParameter pLocationID = new SqlParameter("LocationID", Convert2DBnull(obj.LocationID));

            pLocationID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pLocationID);

            SqlParameter pCreated = new SqlParameter("Created", Convert2DBnull(obj.Created));

            pCreated.SqlDbType = SqlDbType.DateTime;
            cmd.Parameters.Add(pCreated);

            SqlParameter pCreatedBy = new SqlParameter("CreatedBy", Convert2DBnull(obj.CreatedBy));

            pCreatedBy.SqlDbType = SqlDbType.NVarChar;
            cmd.Parameters.Add(pCreatedBy);

            SqlParameter pDetailID = new SqlParameter("DetailID", Convert2DBnull(obj.DetailID));

            pDetailID.SqlDbType = SqlDbType.UniqueIdentifier;
            cmd.Parameters.Add(pDetailID);

            return(cmd.ExecuteNonQuery());
        }