public static TransferDetail GetDetailByDetailID(int transferDetailID, string executedBy)
        {
            TransferDetail transferDetail = null;

            try
            {
                Database  db  = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_TransferDetail_Select);

                db.AddInParameter(cmd, "TransferDetailID", DbType.Int32, transferDetailID);

                DataSet ds = db.ExecuteDataSet(cmd);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0] != null)
                {
                    transferDetail = Utility.DataTableToCollection <TransferDetail>(ds.Tables[0]).FirstOrDefault();
                }
            }

            catch (Exception ex)
            {
                transferDetail = null;
            }

            return(transferDetail);
        }
        protected static bool UpdateDetail(TransferDetail transferDetail, DbTransaction pTransaction, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database  db  = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_TransferDetail_Update);

                db.AddInParameter(cmd, "TransferDetailID", DbType.Int32, transferDetail.TransferDetailID);
                db.AddInParameter(cmd, "ItemID", DbType.Int32, transferDetail.ItemID);
                db.AddInParameter(cmd, "QtyTransferred", DbType.Int32, transferDetail.QtyTransferred);
                db.AddInParameter(cmd, "QtyReceived", DbType.Int32, transferDetail.QtyReceived);
                db.AddInParameter(cmd, "UpdatedBY", DbType.Int32, transferDetail.UpdatedBY);
                //db.AddInParameter(cmd, "UpdatedDate", DbType.Int32, transferDetail.UpdatedDate);

                db.ExecuteNonQuery(cmd, pTransaction);
                rslt = true;
            }

            catch (Exception ex)
            {
                rslt = false;
                throw ex;
            }

            return(rslt);
        }
        protected static bool InsertDetail(TransferDetail transferDetail, DbTransaction pTransaction, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database  db  = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_TransferDetail_Insert);

                db.AddInParameter(cmd, "TransferID", DbType.Int32, transferDetail.TransferID);
                db.AddInParameter(cmd, "ItemID", DbType.Int32, transferDetail.ItemID);
                db.AddInParameter(cmd, "QtyTransferred", DbType.Int32, transferDetail.QtyTransferred);

                db.AddInParameter(cmd, "CreatedBy", DbType.Int32, transferDetail.CreatedBy);

                db.AddOutParameter(cmd, "NewID", DbType.Int32, 4);

                db.ExecuteNonQuery(cmd, pTransaction);

                int newID = 0;
                int.TryParse(db.GetParameterValue(cmd, "NewID").ToString(), out newID);

                if (newID > 0)
                {
                    rslt = true;
                }
            }

            catch (Exception ex)
            {
                rslt = false;
                throw ex;
            }

            return(rslt);
        }
        protected static bool UpdateDetail(TransferDetail transferDetail, DbTransaction pTransaction, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_TransferDetail_Update);

                db.AddInParameter(cmd, "TransferDetailID", DbType.Int32, transferDetail.TransferDetailID);
                db.AddInParameter(cmd, "ItemID", DbType.Int32, transferDetail.ItemID);
                db.AddInParameter(cmd, "QtyTransferred", DbType.Int32, transferDetail.QtyTransferred);
                db.AddInParameter(cmd, "QtyReceived", DbType.Int32, transferDetail.QtyReceived);
                db.AddInParameter(cmd, "UpdatedBY", DbType.Int32, transferDetail.UpdatedBY);
                //db.AddInParameter(cmd, "UpdatedDate", DbType.Int32, transferDetail.UpdatedDate);

                db.ExecuteNonQuery(cmd, pTransaction);
                     rslt = true;
            }

            catch (Exception ex)
            {
                rslt = false;
                throw ex;
            }

            return rslt;
        }
        protected static bool InsertDetail(TransferDetail transferDetail, DbTransaction pTransaction, string executedBy)
        {
            bool rslt = false;

            try
            {
                Database db = DatabaseFactory.CreateDatabase(Constants.DBConnection);
                DbCommand cmd = db.GetStoredProcCommand(Constants.SP_TransferDetail_Insert);

                db.AddInParameter(cmd, "TransferID", DbType.Int32, transferDetail.TransferID);
                db.AddInParameter(cmd, "ItemID", DbType.Int32, transferDetail.ItemID);
                db.AddInParameter(cmd, "QtyTransferred", DbType.Int32, transferDetail.QtyTransferred);

                db.AddInParameter(cmd, "CreatedBy", DbType.Int32, transferDetail.CreatedBy);

                db.AddOutParameter(cmd, "NewID", DbType.Int32, 4);

                db.ExecuteNonQuery(cmd, pTransaction);

                int newID = 0;
                int.TryParse(db.GetParameterValue(cmd, "NewID").ToString(), out newID);

                if (newID > 0)
                    rslt = true;
            }

            catch (Exception ex)
            {
                rslt = false;
                throw ex;
            }

            return rslt;
        }